diff --git a/lib/docker_client.rb b/lib/docker_client.rb index f0799d8f..1c02f379 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -155,11 +155,16 @@ class DockerClient `docker pull #{docker_image}` if docker_image end + #this sends the command to run whatever is defined in the backend def send_command(command, container, &block) Timeout.timeout(@execution_environment.permitted_execution_time.to_i) do stderr = [] stdout = [] - container.attach(stdin: StringIO.new(command)) do |stream, chunk| + # map command in a shell call, maybe add -c + command = ['bash', '-c', command] + # lets call the command, but we do not want the container to stop afterwards + # thats why we use exec. If its ok do stop the container this could be assign instead + container.exec(command) do |stream, chunk| block.call(stream, chunk) if block_given? if stream == :stderr stderr.push(chunk) @@ -173,7 +178,11 @@ class DockerClient {status: :timeout} ensure Concurrent::Future.execute { + # If you do not want to reuse running container you could use: #self.class.destroy_container(container) + # This could be moved to an execution environment specific setting + + # we may need to stop the exec call here..!!! FileUtils.rm_rf(local_workspace_path(container)) if local_workspace_path(container) FileUtils.mkdir(local_workspace_path) DockerContainerPool.return_container(container, @execution_environment) diff --git a/lib/docker_container_pool.rb b/lib/docker_container_pool.rb index 3ca644df..7d58f138 100644 --- a/lib/docker_container_pool.rb +++ b/lib/docker_container_pool.rb @@ -21,7 +21,6 @@ class DockerContainerPool end def self.return_container(container, execution_environment) - #container.start() @containers[execution_environment.id].push(container) end