diff --git a/hoosegow.gemspec b/hoosegow.gemspec index 7426595..4e1ce0d 100644 --- a/hoosegow.gemspec +++ b/hoosegow.gemspec @@ -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 diff --git a/lib/hoosegow/docker.rb b/lib/hoosegow/docker.rb index 359d9d0..716edb0 100644 --- a/lib/hoosegow/docker.rb +++ b/lib/hoosegow/docker.rb @@ -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] @@ -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. @@ -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