Class: Docker::API::Client
- Inherits:
-
Object
- Object
- Docker::API::Client
- Defined in:
- lib/docker/api/client.rb
Overview
A connection to one Docker daemon, and the way in to everything else.
A client owns its configuration and its connection. There is no global state behind it: two clients addressing two daemons share nothing, so a process can talk to a local daemon and a remote builder at the same time without either one noticing.
Instance Attribute Summary collapse
-
#config ⇒ Docker::API::Config
readonly
This client's frozen configuration.
-
#connection ⇒ Docker::API::Connection
readonly
The connection in use.
Instance Method Summary collapse
-
#api_version ⇒ String?
The negotiated Engine API version.
- #containers ⇒ Docker::API::Containers
- #images ⇒ Docker::API::Images
-
#initialize(url: nil, tls: nil, api_version: :negotiate, logger: nil, read_timeout: 60, open_timeout: 10, transport: nil, env: ENV) ⇒ Client
constructor
A new instance of Client.
- #networks ⇒ Docker::API::Networks
-
#operations ⇒ Docker::API::Operations
Every Engine API operation, one method each.
- #system ⇒ Docker::API::System
- #to_s ⇒ String (also: #inspect)
- #volumes ⇒ Docker::API::Volumes
Constructor Details
#initialize(url: nil, tls: nil, api_version: :negotiate, logger: nil, read_timeout: 60, open_timeout: 10, transport: nil, env: ENV) ⇒ Client
Returns a new instance of Client.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/docker/api/client.rb', line 48 def initialize(url: nil, tls: nil, api_version: :negotiate, logger: nil, read_timeout: 60, open_timeout: 10, transport: nil, env: ENV) @config = Config.from_env( env, url: url, api_version: api_version, read_timeout: read_timeout, open_timeout: open_timeout, **(tls.nil? ? {} : { tls: tls }) ) @connection = Connection.new( transport: transport || Transport.for( url: config.url, tls: config.tls, open_timeout: config.open_timeout ), api_version: config.api_version, logger: logger, read_timeout: config.read_timeout, open_timeout: config.open_timeout ) end |
Instance Attribute Details
#config ⇒ Docker::API::Config (readonly)
Returns this client's frozen configuration.
29 30 31 |
# File 'lib/docker/api/client.rb', line 29 def config @config end |
#connection ⇒ Docker::API::Connection (readonly)
Returns the connection in use.
32 33 34 |
# File 'lib/docker/api/client.rb', line 32 def connection @connection end |
Instance Method Details
#api_version ⇒ String?
Returns the negotiated Engine API version.
106 107 108 |
# File 'lib/docker/api/client.rb', line 106 def api_version connection.api_version end |
#containers ⇒ Docker::API::Containers
81 82 83 |
# File 'lib/docker/api/client.rb', line 81 def containers @containers ||= Containers.new(self) end |
#images ⇒ Docker::API::Images
86 87 88 |
# File 'lib/docker/api/client.rb', line 86 def images @images ||= Images.new(self) end |
#networks ⇒ Docker::API::Networks
91 92 93 |
# File 'lib/docker/api/client.rb', line 91 def networks @networks ||= Networks.new(self) end |
#operations ⇒ Docker::API::Operations
Every Engine API operation, one method each.
This is public API rather than an escape hatch. The ergonomic collections below cover what most code needs; anything they have not grown sugar for is reachable here, fully documented and typed, with no loss of capability.
76 77 78 |
# File 'lib/docker/api/client.rb', line 76 def operations @operations ||= Operations.new(connection) end |
#system ⇒ Docker::API::System
101 102 103 |
# File 'lib/docker/api/client.rb', line 101 def system @system ||= System.new(self) end |
#to_s ⇒ String Also known as: inspect
111 112 113 |
# File 'lib/docker/api/client.rb', line 111 def to_s "#<Docker::API::Client url=#{config.url}>" end |
#volumes ⇒ Docker::API::Volumes
96 97 98 |
# File 'lib/docker/api/client.rb', line 96 def volumes @volumes ||= Volumes.new(self) end |