From 36002f95edcb4f7664d03c42e7f96bcf56232903 Mon Sep 17 00:00:00 2001 From: Ben Firshman Date: Thu, 2 Jan 2014 20:51:35 +0000 Subject: [PATCH] Try connecting to localdocker:4243 See https://github.com/noplay/docker-osx/pull/22 --- fig/cli/utils.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/fig/cli/utils.py b/fig/cli/utils.py index 1094b5e77..a1ff0c008 100644 --- a/fig/cli/utils.py +++ b/fig/cli/utils.py @@ -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)))