Try connecting to localdocker:4243

See https://github.com/noplay/docker-osx/pull/22
This commit is contained in:
Ben Firshman 2014-01-02 20:51:35 +00:00
parent 0a92cbfa4d
commit 36002f95ed
1 changed files with 18 additions and 10 deletions

View File

@ -83,21 +83,29 @@ def docker_url():
return os.environ['DOCKER_URL']
socket_path = '/var/run/docker.sock'
tcp_hosts = [
('localdocker', 4243),
('127.0.0.1', 4243),
]
tcp_host = '127.0.0.1'
tcp_port = 4243
if os.path.exists(socket_path):
return 'unix://%s' % socket_path
try:
s = socket.socket()
s.connect((tcp_host, tcp_port))
s.close()
return 'http://%s:%s' % (tcp_host, tcp_port)
except:
pass
for host, port in tcp_hosts:
try:
s = socket.create_connection((host, port), timeout=1)
s.close()
return 'http://%s:%s' % (host, port)
except:
pass
raise UserError("""
Couldn't find Docker daemon - tried %s and %s:%s.
If it's running elsewhere, specify a url with DOCKER_URL.
""" % (socket_path, tcp_host, tcp_port))
Couldn't find Docker daemon - tried:
unix://%s
%s
If it's running elsewhere, specify a url with DOCKER_URL.
""" % (socket_path, '\n'.join('tcp://%s:%s' % h for h in tcp_hosts)))