Sha256: 281dc3e758f250be07b2607ee20f55268ac901e71603754c17d7788a9b386413
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
# This class represents a Docker Container. It's important to note that nothing # is cached so that the information is always up to date. class Docker::Container include Docker::Model include Docker::Error set_resource_prefix '/containers' set_create_request do |body| response = connection.post('/containers/create', nil, :body => body.to_json) @id = Docker::Util.parse_json(response)['Id'] self end # Get more information about the Container. request :get, :json # Start the Container. request :post, :start # Inspect the Container's changes to the filesysetem request :get, :changes # Stop the Container. request :post, :stop # Kill the Container. request :post, :kill # Restart the Container request :post, :restart # Wait for the current command to finish executing. def wait(time = 60) resp = connection.post("/containers/#{id}/wait", nil, :read_timeout => time) Docker::Util.parse_json(resp) end # Export the Container as a tar. def export(&block) connection.get("/containers/#{id}/export", nil, :response_block => block) true end # Attach to a container's standard streams / logs. def attach(options = {}) options = { :stream => true, :stdout => true }.merge(options) connection.post("/containers/#{id}/attach", options) end # Create an Image from a Container's change.s 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
docker-api-1.1.2 | lib/docker/container.rb |