Class: Docker::API::Containers
- Inherits:
-
Collection
- Object
- Collection
- Docker::API::Containers
- Defined in:
- lib/docker/api/collections/containers.rb
Overview
The containers on a daemon.
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
-
#all(all: false, limit: nil, size: false, filters: nil) ⇒ Array<Docker::API::Container>
List containers.
-
#create(name: nil, platform: nil, **attributes) ⇒ Docker::API::Container
Create a container.
-
#get(id, size: false) ⇒ Docker::API::Container
Fetch one container.
-
#prune(filters: nil) ⇒ Hash
Remove stopped containers.
Methods inherited from Collection
#exist?, #find, #initialize, #to_s
Constructor Details
This class inherits a constructor from Docker::API::Collection
Instance Method Details
#all(all: false, limit: nil, size: false, filters: nil) ⇒ Array<Docker::API::Container>
List containers.
22 23 24 25 |
# File 'lib/docker/api/collections/containers.rb', line 22 def all(all: false, limit: nil, size: false, filters: nil) operations.container_list(all: all, limit: limit, size: size, filters: filters) .json!.map { |payload| Container.new(client: client, raw: payload, partial: true) } end |
#create(name: nil, platform: nil, **attributes) ⇒ Docker::API::Container
Create a container.
Body attributes may be given in snake_case and are converted to the
daemon's spelling; keys already in the daemon's convention are passed
through untouched, so a configuration copied out of Docker's own
documentation works as-is. Only top-level keys are converted -- nested
maps such as Labels and PortBindings have keys that are data.
62 63 64 65 66 67 |
# File 'lib/docker/api/collections/containers.rb', line 62 def create(name: nil, platform: nil, **attributes) response = operations.container_create( body: Body.build(attributes), name: name, platform: platform ) get(response.json!["Id"]) end |
#get(id, size: false) ⇒ Docker::API::Container
Fetch one container.
33 34 35 36 37 38 39 |
# File 'lib/docker/api/collections/containers.rb', line 33 def get(id, size: false) Container.new( client: client, raw: operations.container_inspect(id: id, size: size).json, partial: false ) end |
#prune(filters: nil) ⇒ Hash
Remove stopped containers.
73 74 75 |
# File 'lib/docker/api/collections/containers.rb', line 73 def prune(filters: nil) operations.container_prune(filters: filters).json end |