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'] return os.environ['DOCKER_URL']
socket_path = '/var/run/docker.sock' socket_path = '/var/run/docker.sock'
tcp_hosts = [
('localdocker', 4243),
('127.0.0.1', 4243),
]
tcp_host = '127.0.0.1' tcp_host = '127.0.0.1'
tcp_port = 4243 tcp_port = 4243
if os.path.exists(socket_path): if os.path.exists(socket_path):
return 'unix://%s' % socket_path return 'unix://%s' % socket_path
try: for host, port in tcp_hosts:
s = socket.socket() try:
s.connect((tcp_host, tcp_port)) s = socket.create_connection((host, port), timeout=1)
s.close() s.close()
return 'http://%s:%s' % (tcp_host, tcp_port) return 'http://%s:%s' % (host, port)
except: except:
pass pass
raise UserError(""" raise UserError("""
Couldn't find Docker daemon - tried %s and %s:%s. Couldn't find Docker daemon - tried:
If it's running elsewhere, specify a url with DOCKER_URL.
""" % (socket_path, tcp_host, tcp_port)) 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)))