Docker

The top-level module for this gem. It's purpose is to hold global configuration variables that are used as defaults in other classes.

Constants

API_VERSION

The version of the compatible Docker remote API.

VERSION

The version of the docker-api gem.

Attributes

creds[RW]
logger[RW]

Public Class Methods

authenticate!(options = {}) click to toggle source

Login to the Docker registry.

# File lib/docker.rb, line 75
def authenticate!(options = {})
  creds = options.to_json
  connection.post('/auth', {}, :body => creds)
  @creds = creds
  true
rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError
  raise Docker::Error::AuthenticationError
end
connection() click to toggle source
# File lib/docker.rb, line 56
def connection
  @connection ||= Connection.new(url, options)
end
default_socket_url() click to toggle source
# File lib/docker.rb, line 25
def default_socket_url
  'unix:///var/run/docker.sock'
end
env_url() click to toggle source
# File lib/docker.rb, line 29
def env_url
  ENV['DOCKER_URL']
end
info() click to toggle source

Get more information about the Docker server.

# File lib/docker.rb, line 70
def info
  Util.parse_json(connection.get('/info'))
end
options() click to toggle source
# File lib/docker.rb, line 42
def options
  @options ||= {}
end
options=(new_options) click to toggle source
# File lib/docker.rb, line 51
def options=(new_options)
  @options = new_options
  reset_connection!
end
reset_connection!() click to toggle source
# File lib/docker.rb, line 60
def reset_connection!
  @connection = nil
end
url() click to toggle source
# File lib/docker.rb, line 33
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) click to toggle source
# File lib/docker.rb, line 46
def url=(new_url)
  @url = new_url
  reset_connection!
end
validate_version!() click to toggle source

When the correct version of Docker is installed, returns true. Otherwise, raises a VersionError.

# File lib/docker.rb, line 86
def validate_version!
  Docker.info
  true
rescue Docker::Error::DockerError
  raise Docker::Error::VersionError, "Expected API Version: #{API_VERSION}"
end
version() click to toggle source

Get the version of Go, Docker, and optionally the Git commit.

# File lib/docker.rb, line 65
def version
  Util.parse_json(connection.get('/version'))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.