Module: Docker
- Defined in:
- lib/docker.rb,
lib/docker/version.rb
Overview
The top-level module for this gem. Its purpose is to hold global configuration variables that are used as defaults in other classes.
Defined Under Namespace
Modules: Base, Error, Util Classes: Connection, Container, Event, Exec, Image, ImageTask, Messages, MessagesStack, Network, Volume
Constant Summary collapse
- VERSION =
The version of the docker-api gem.
'2.4.0'
Class Method Summary collapse
-
.authenticate!(options = {}, connection = self.connection) ⇒ Object
Login to the Docker registry.
- .connection ⇒ Object
-
.creds ⇒ Object
Returns the value of attribute creds.
-
.creds=(value) ⇒ Object
Sets the attribute creds.
- .default_socket_url ⇒ Object
- .env_options ⇒ Object
- .env_url ⇒ Object
-
.info(connection = self.connection) ⇒ Object
Get more information about the Docker server.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.logger=(value) ⇒ Object
Sets the attribute logger.
- .options ⇒ Object
- .options=(new_options) ⇒ Object
-
.ping(connection = self.connection) ⇒ Object
Ping the Docker server.
-
.podman?(connection = self.connection) ⇒ Boolean
Determine if the server is podman or docker.
- .reset! ⇒ Object
- .reset_connection! ⇒ Object
-
.rootless?(connection = self.connection) ⇒ Boolean
Determine if the session is rootless.
- .ssl_options ⇒ Object
- .url ⇒ Object
- .url=(new_url) ⇒ Object
-
.version(connection = self.connection) ⇒ Object
Get the version of Go, Docker, and optionally the Git commit.
Class Method Details
.authenticate!(options = {}, connection = self.connection) ⇒ Object
Login to the Docker registry.
135 136 137 138 139 140 141 142 |
# File 'lib/docker.rb', line 135 def authenticate!( = {}, connection = self.connection) creds = MultiJson.dump() connection.post('/auth', {}, body: creds) @creds = creds true rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError raise Docker::Error::AuthenticationError end |
.connection ⇒ Object
95 96 97 |
# File 'lib/docker.rb', line 95 def connection @connection ||= Connection.new(url, ) end |
.creds ⇒ Object
Returns the value of attribute creds.
24 25 26 |
# File 'lib/docker.rb', line 24 def creds @creds end |
.creds=(value) ⇒ Object
Sets the attribute creds
24 25 26 |
# File 'lib/docker.rb', line 24 def creds=(value) @creds = value end |
.default_socket_url ⇒ Object
41 42 43 |
# File 'lib/docker.rb', line 41 def default_socket_url 'unix:///var/run/docker.sock' end |
.env_options ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/docker.rb', line 49 def if cert_path = ENV['DOCKER_CERT_PATH'] { client_cert: File.join(cert_path, 'cert.pem'), client_key: File.join(cert_path, 'key.pem'), ssl_ca_file: File.join(cert_path, 'ca.pem'), scheme: 'https' }.merge() else {} end end |
.env_url ⇒ Object
45 46 47 |
# File 'lib/docker.rb', line 45 def env_url ENV['DOCKER_URL'] || ENV['DOCKER_HOST'] end |
.info(connection = self.connection) ⇒ Object
Get more information about the Docker server.
115 116 117 |
# File 'lib/docker.rb', line 115 def info(connection = self.connection) connection.info end |
.logger ⇒ Object
Returns the value of attribute logger.
24 25 26 |
# File 'lib/docker.rb', line 24 def logger @logger end |
.logger=(value) ⇒ Object
Sets the attribute logger
24 25 26 |
# File 'lib/docker.rb', line 24 def logger=(value) @logger = value end |
.options ⇒ Object
81 82 83 |
# File 'lib/docker.rb', line 81 def @options ||= end |
.options=(new_options) ⇒ Object
90 91 92 93 |
# File 'lib/docker.rb', line 90 def () @options = .merge( || {}) reset_connection! end |
.ping(connection = self.connection) ⇒ Object
Ping the Docker server.
120 121 122 |
# File 'lib/docker.rb', line 120 def ping(connection = self.connection) connection.ping end |
.podman?(connection = self.connection) ⇒ Boolean
Determine if the server is podman or docker.
125 126 127 |
# File 'lib/docker.rb', line 125 def podman?(connection = self.connection) connection.podman? end |
.reset! ⇒ Object
99 100 101 102 103 |
# File 'lib/docker.rb', line 99 def reset! @url = nil @options = nil reset_connection! end |
.reset_connection! ⇒ Object
105 106 107 |
# File 'lib/docker.rb', line 105 def reset_connection! @connection = nil end |
.rootless?(connection = self.connection) ⇒ Boolean
Determine if the session is rootless.
130 131 132 |
# File 'lib/docker.rb', line 130 def rootless?(connection = self.connection) connection.rootless? end |
.ssl_options ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/docker.rb', line 62 def if ENV['DOCKER_SSL_VERIFY'] == 'false' { ssl_verify_peer: false } else {} end end |
.url ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/docker.rb', line 72 def url @url ||= env_url || default_socket_url # docker uses a default notation tcp:// which means tcp://localhost:2375 if @url == 'tcp://' @url = 'tcp://localhost:2375' end @url end |
.url=(new_url) ⇒ Object
85 86 87 88 |
# File 'lib/docker.rb', line 85 def url=(new_url) @url = new_url reset_connection! end |
.version(connection = self.connection) ⇒ Object
Get the version of Go, Docker, and optionally the Git commit.
110 111 112 |
# File 'lib/docker.rb', line 110 def version(connection = self.connection) connection.version end |