Skip to content

Instantly share code, notes, and snippets.

@mizzy
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save mizzy/b2f441fa9d60dec304d0 to your computer and use it in GitHub Desktop.

Select an option

Save mizzy/b2f441fa9d60dec304d0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'docker'
image = Docker::Image.get('ubuntu')
loop do
container = Docker::Container::create(
'Image' => image.id,
'Cmd' => '/bin/ls',
)
begin
container.start
begin
stdout, stderr = container.attach
result = container.wait
p stdout
rescue
container.kill
end
ensure
container.delete
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment