lib/docker/remote/client.rb in docker-remote-0.5.0 vs lib/docker/remote/client.rb in docker-remote-0.5.1

- old
+ new

@@ -1,7 +1,8 @@ require 'json' require 'net/http' +require 'socket' require 'uri' module Docker module Remote class DockerRemoteError < StandardError; end @@ -117,23 +118,24 @@ end def registry_uri @registry_uri ||= begin host_port, *rest = registry_url.split('/') - host, port = host_port.split(':') + host, orig_port = host_port.split(':') - ports = if port - [port.to_i] + port = if orig_port + orig_port.to_i elsif prt = PORTMAP[host] - [prt] + prt else - STANDARD_PORTS + STANDARD_PORTS.find do |prt| + can_connect?(host, prt) + end end - port = ports.find { |port| can_connect?(host, port) } - unless port - raise DockerRemoteError, "couldn't determine what port to connect to" + raise DockerRemoteError, + "couldn't determine what port to connect to for '#{registry_url}'" end scheme = port == DEFAULT_PORT ? 'https' : 'http' URI.parse("#{scheme}://#{host}:#{port}/#{rest.join('/')}") end