Module: Docker
- Defined in:
- lib/docker.rb,
lib/docker/version.rb
Overview
The top-level module for this gem. It’s 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, Image, ImageTask, Messages
Constant Summary collapse
- VERSION =
The version of the docker-api gem.
'1.10.7'
- API_VERSION =
The version of the compatible Docker remote API.
'1.10'
Class Method Summary collapse
-
.authenticate!(options = {}) ⇒ 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_url ⇒ Object
-
.info ⇒ 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
- .reset_connection! ⇒ Object
- .url ⇒ Object
- .url=(new_url) ⇒ Object
-
.validate_version! ⇒ Object
When the correct version of Docker is installed, returns true.
-
.version ⇒ Object
Get the version of Go, Docker, and optionally the Git commit.
Class Method Details
.authenticate!(options = {}) ⇒ Object
Login to the Docker registry.
77 78 79 80 81 82 83 84 |
# File 'lib/docker.rb', line 77 def authenticate!( = {}) creds = .to_json connection.post('/auth', {}, :body => creds) @creds = creds true rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError raise Docker::Error::AuthenticationError end |
.connection ⇒ Object
58 59 60 |
# File 'lib/docker.rb', line 58 def connection @connection ||= Connection.new(url, ) end |
.creds ⇒ Object
Returns the value of attribute creds.
14 15 16 |
# File 'lib/docker.rb', line 14 def creds @creds end |
.creds=(value) ⇒ Object
Sets the attribute creds
14 15 16 |
# File 'lib/docker.rb', line 14 def creds=(value) @creds = value end |
.default_socket_url ⇒ Object
27 28 29 |
# File 'lib/docker.rb', line 27 def default_socket_url 'unix:///var/run/docker.sock' end |
.env_url ⇒ Object
31 32 33 |
# File 'lib/docker.rb', line 31 def env_url ENV['DOCKER_URL'] end |
.info ⇒ Object
Get more information about the Docker server.
72 73 74 |
# File 'lib/docker.rb', line 72 def info Util.parse_json(connection.get('/info')) end |
.logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/docker.rb', line 14 def logger @logger end |
.logger=(value) ⇒ Object
Sets the attribute logger
14 15 16 |
# File 'lib/docker.rb', line 14 def logger=(value) @logger = value end |
.options ⇒ Object
44 45 46 |
# File 'lib/docker.rb', line 44 def @options ||= {} end |
.options=(new_options) ⇒ Object
53 54 55 56 |
# File 'lib/docker.rb', line 53 def () @options = reset_connection! end |
.reset_connection! ⇒ Object
62 63 64 |
# File 'lib/docker.rb', line 62 def reset_connection! @connection = nil end |
.url ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/docker.rb', line 35 def url @url ||= ENV['DOCKER_URL'] || ENV['DOCKER_HOST'] || default_socket_url # docker uses a default notation tcp:// which means tcp://localhost:4243 if @url == 'tcp://' @url = 'tcp://localhost:4243' end @url end |
.url=(new_url) ⇒ Object
48 49 50 51 |
# File 'lib/docker.rb', line 48 def url=(new_url) @url = new_url reset_connection! end |
.validate_version! ⇒ Object
When the correct version of Docker is installed, returns true. Otherwise, raises a VersionError.
88 89 90 91 92 93 |
# File 'lib/docker.rb', line 88 def validate_version! Docker.info true rescue Docker::Error::DockerError raise Docker::Error::VersionError, "Expected API Version: #{API_VERSION}" end |
.version ⇒ Object
Get the version of Go, Docker, and optionally the Git commit.
67 68 69 |
# File 'lib/docker.rb', line 67 def version Util.parse_json(connection.get('/version')) end |