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.



38
39
40
41
42
43
44
45
46
47
# File 'lib/docker/container.rb', line 38

def attach(options = {})
  options = { :stream => true, :stdout => true }.merge(options)
  self.connection.post(
    :path    => "/containers/#{self.id}/attach",
    :headers => { 'Content-Type' => 'text/plain',
                  'User-Agent' => "Docker-Client/0.4.6" },
    :query   => options,
    :expects => (200..204)
  ).body
end

#commit(options = {}) ⇒ Object

Create an Image from a Container’s change.s



50
51
52
53
54
# File 'lib/docker/container.rb', line 50

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