Skip to content

Docker remote api data streaming #2786

@hychan

Description

@hychan

I'm using Ruby gem 'docker-api' with a Docker daemon running on a remote server.

I ran into timeout issue when I want to get output from running a command inside the container.

create an image

image = Docker::Image.create('fromImage'=>'base')

insert a local file into the image

image.insert_local('localPath'=>['/root/docker_scripts/install_prereqs.sh', '/root/docker_scripts/weaver_script.sh'], 'outputPath'=>'/tmp/')

get the image id from the response

image_data = eval("image.json")
puts image.json
image_id = image_data["id"]
inputs = Hash.new
inputs["Image"] = image_id
inputs["Cmd"] = ['ls -al']

create a container with the image id and the command 'ls -al'

myContainer = Docker::Container.create(inputs)

start the container and stream the output

myContainer.tap(&:start).attach {|stream,chunk| puts "#{stream}: #{chunk}"}

RESPONSE:
read time out reached
.docker_9f738e00-3424-0131-e558-525400c6ff8e [Status: failed]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions