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: Error, Util Classes: Connection, Container, Image
Constant Summary collapse
- VERSION =
The version of the docker-api gem.
'1.6.0'- API_VERSION =
The version of the compatible Docker remote API.
'1.4'
Instance Attribute Summary collapse
-
#creds ⇒ Object
readonly
Returns the value of attribute creds.
Class Method Summary collapse
-
.authenticate!(options = {}) ⇒ Object
Login to the Docker registry.
- .connection ⇒ Object
- .default_socket_url ⇒ Object
- .env_url ⇒ Object
-
.info ⇒ Object
Get more information about the Docker server.
- .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.
Instance Attribute Details
#creds ⇒ Object (readonly)
Returns the value of attribute creds.
11 12 13 |
# File 'lib/docker.rb', line 11 def creds @creds end |
Class Method Details
.authenticate!(options = {}) ⇒ Object
Login to the Docker registry.
58 59 60 61 62 |
# File 'lib/docker.rb', line 58 def authenticate!( = {}) @creds = .to_json connection.post(:path => '/auth', :body => @creds) true end |
.connection ⇒ Object
39 40 41 |
# File 'lib/docker.rb', line 39 def connection @connection ||= Connection.new(url, ) end |
.default_socket_url ⇒ Object
13 14 15 |
# File 'lib/docker.rb', line 13 def default_socket_url 'unix:///var/run/docker.sock' end |
.env_url ⇒ Object
17 18 19 |
# File 'lib/docker.rb', line 17 def env_url ENV['DOCKER_URL'] end |
.info ⇒ Object
Get more information about the Docker server.
53 54 55 |
# File 'lib/docker.rb', line 53 def info Util.parse_json(connection.get('/info')) end |
.options ⇒ Object
25 26 27 |
# File 'lib/docker.rb', line 25 def @options ||= {} end |
.options=(new_options) ⇒ Object
34 35 36 37 |
# File 'lib/docker.rb', line 34 def () @options = reset_connection! end |
.reset_connection! ⇒ Object
43 44 45 |
# File 'lib/docker.rb', line 43 def reset_connection! @connection = nil end |
.url ⇒ Object
21 22 23 |
# File 'lib/docker.rb', line 21 def url @url ||= ENV['DOCKER_URL'] || default_socket_url end |
.url=(new_url) ⇒ Object
29 30 31 32 |
# File 'lib/docker.rb', line 29 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.
66 67 68 69 70 71 |
# File 'lib/docker.rb', line 66 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.
48 49 50 |
# File 'lib/docker.rb', line 48 def version Util.parse_json(connection.get('/version')) end |