Class: Docker::Container

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/docker/container.rb

Overview

This class represents a Docker Container. It’s important to note that nothing is cached so that the information is always up to date.

Instance Attribute Summary

Attributes included from Model

#connection, #id

Instance Method Summary collapse

Methods included from Model

included, #initialize, #to_s

Instance Method Details

#attach(options = {}) ⇒ Object

Attach to a container’s standard streams / logs.



36
37
38
39
# File 'lib/docker/container.rb', line 36

def attach(options = {})
  options = { :stream => true, :stdout => true }.merge(options)
  connection.post("/containers/#{id}/attach", options)
end

#commit(options = {}) ⇒ Object

Create an Image from a Container’s change.s



42
43
44
45
46
# File 'lib/docker/container.rb', line 42

def commit(options = {})
  options.merge!('container' => self.id[0..7])
  hash = JSON.parse(connection.request(:post, '/commit', options))
  Docker::Image.send(:new, :id => hash['Id'], :connection => self.connection)
end

#export(&block) ⇒ Object

Export the Container as a tar.



30
31
32
33
# File 'lib/docker/container.rb', line 30

def export(&block)
  connection.get("/containers/#{id}/export", nil, :response_block => block)
  true
end