Skip to content
This repository was archived by the owner on May 9, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hoosegow.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rspec', '>= 2.14.1', '~> 2.14'
s.add_runtime_dependency 'msgpack', '>= 0.5.6', '~> 0.5'
s.add_runtime_dependency 'yajl-ruby', '>= 1.1.0', '~> 1.1'
s.add_runtime_dependency 'docker-api', '~> 1.13.6'
s.add_runtime_dependency 'docker-api', '~> 1.19'
end
14 changes: 11 additions & 3 deletions lib/hoosegow/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Docker
# :Other - any option with a capitalized key will be passed on
# to the 'create container' call. See http://docs.docker.io/en/latest/reference/api/docker_remote_api_v1.9/#create-a-container
def initialize(options = {})
::Docker.url = docker_url options
set_docker_url! options
@after_create = options[:after_create]
@after_start = options[:after_start]
@after_stop = options[:after_stop]
Expand Down Expand Up @@ -168,6 +168,13 @@ def image_exist?(name)
end

private
# Private: Set the docker URL, if related options are present.
def set_docker_url!(options)
if url = docker_url(options)
::Docker.url = url
end
end

# Private: Get the URL to use for communicating with Docker. If a host and/or
# port a present, a TCP socket URL will be generated. Otherwise a Unix
# socket will be used.
Expand All @@ -184,9 +191,10 @@ def docker_url(options)
host = options[:host] || DEFAULT_HOST
port = options[:port] || DEFAULT_PORT
"tcp://#{host}:#{port}"
else
path = options[:socket] || DEFAULT_SOCKET
elsif path = options[:socket]
"unix://#{path}"
else
nil
end
end

Expand Down