Module: Docker

Extended by:
Docker
Included in:
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, Model Classes: Connection, Container, Image

Constant Summary collapse

VERSION =
'1.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credsObject (readonly)

Returns the value of attribute creds.



12
13
14
# File 'lib/docker.rb', line 12

def creds
  @creds
end

Instance Method Details

#authenticate!(options = {}) ⇒ Object

Login to the Docker registry.



51
52
53
54
55
# File 'lib/docker.rb', line 51

def authenticate!(options = {})
  @creds = options.to_json
  connection.post(:path => '/auth', :body => @creds)
  true
end

#connectionObject



32
33
34
# File 'lib/docker.rb', line 32

def connection
  @connection ||= Connection.new(url, options)
end

#infoObject

Get more information about the Docker server.



46
47
48
# File 'lib/docker.rb', line 46

def info
  connection.json_request(:get, '/info')
end

#optionsObject



18
19
20
# File 'lib/docker.rb', line 18

def options
  @options ||= { :port => 4243 }
end

#options=(new_options) ⇒ Object



27
28
29
30
# File 'lib/docker.rb', line 27

def options=(new_options)
  @options = { :port => 4243 }.merge(new_options)
  reset_connection!
end

#reset_connection!Object



36
37
38
# File 'lib/docker.rb', line 36

def reset_connection!
  @connection = nil
end

#urlObject



14
15
16
# File 'lib/docker.rb', line 14

def url
  @url ||= 'http://localhost'
end

#url=(new_url) ⇒ Object



22
23
24
25
# File 'lib/docker.rb', line 22

def url=(new_url)
  @url = new_url
  reset_connection!
end

#versionObject

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



41
42
43
# File 'lib/docker.rb', line 41

def version
  connection.json_request(:get, '/version')
end