Module: Docker
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, Model, Util Classes: Connection, Container, Image
Constant Summary collapse
- VERSION =
The version of the docker-api gem.
'1.1.1'
- API_VERSION =
The version of the compatible Docker remote API.
'1.3'
Instance Attribute Summary collapse
-
#creds ⇒ Object
readonly
Returns the value of attribute creds.
Instance Method Summary collapse
-
#authenticate!(options = {}) ⇒ Object
Login to the Docker registry.
- #connection ⇒ 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.
13 14 15 |
# File 'lib/docker.rb', line 13 def creds @creds end |
Instance Method Details
#authenticate!(options = {}) ⇒ Object
Login to the Docker registry.
52 53 54 55 56 |
# File 'lib/docker.rb', line 52 def authenticate!( = {}) @creds = .to_json connection.post(:path => '/auth', :body => @creds) true end |
#connection ⇒ Object
33 34 35 |
# File 'lib/docker.rb', line 33 def connection @connection ||= Connection.new(url, ) end |
#info ⇒ Object
Get more information about the Docker server.
47 48 49 |
# File 'lib/docker.rb', line 47 def info Util.parse_json(connection.request(:get, '/info')) end |
#options ⇒ Object
19 20 21 |
# File 'lib/docker.rb', line 19 def @options ||= { :port => 4243 } end |
#options=(new_options) ⇒ Object
28 29 30 31 |
# File 'lib/docker.rb', line 28 def () @options = { :port => 4243 }.merge() reset_connection! end |
#reset_connection! ⇒ Object
37 38 39 |
# File 'lib/docker.rb', line 37 def reset_connection! @connection = nil end |
#url ⇒ Object
15 16 17 |
# File 'lib/docker.rb', line 15 def url @url ||= 'http://localhost' end |
#url=(new_url) ⇒ Object
23 24 25 26 |
# File 'lib/docker.rb', line 23 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.
60 61 62 63 64 65 |
# File 'lib/docker.rb', line 60 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.
42 43 44 |
# File 'lib/docker.rb', line 42 def version Util.parse_json(connection.request(:get, '/version')) end |