mirror of https://github.com/docker/compose.git
Suggest to run Docker for Mac if it isn't running
Instead of suggesting docker-machine. Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This commit is contained in:
parent
6246a2592e
commit
cb076a57b9
|
@ -14,6 +14,7 @@ from requests.packages.urllib3.exceptions import ReadTimeoutError
|
||||||
|
|
||||||
from ..const import API_VERSION_TO_ENGINE_VERSION
|
from ..const import API_VERSION_TO_ENGINE_VERSION
|
||||||
from .utils import call_silently
|
from .utils import call_silently
|
||||||
|
from .utils import is_docker_for_mac_installed
|
||||||
from .utils import is_mac
|
from .utils import is_mac
|
||||||
from .utils import is_ubuntu
|
from .utils import is_ubuntu
|
||||||
|
|
||||||
|
@ -47,16 +48,7 @@ def handle_connection_errors(client):
|
||||||
if e.args and isinstance(e.args[0], ReadTimeoutError):
|
if e.args and isinstance(e.args[0], ReadTimeoutError):
|
||||||
log_timeout_error(client.timeout)
|
log_timeout_error(client.timeout)
|
||||||
raise ConnectionError()
|
raise ConnectionError()
|
||||||
|
exit_with_error(get_conn_error_message(client.base_url))
|
||||||
if call_silently(['which', 'docker']) != 0:
|
|
||||||
if is_mac():
|
|
||||||
exit_with_error(docker_not_found_mac)
|
|
||||||
if is_ubuntu():
|
|
||||||
exit_with_error(docker_not_found_ubuntu)
|
|
||||||
exit_with_error(docker_not_found_generic)
|
|
||||||
if call_silently(['which', 'docker-machine']) == 0:
|
|
||||||
exit_with_error(conn_error_docker_machine)
|
|
||||||
exit_with_error(conn_error_generic.format(url=client.base_url))
|
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
log_api_error(e, client.api_version)
|
log_api_error(e, client.api_version)
|
||||||
raise ConnectionError()
|
raise ConnectionError()
|
||||||
|
@ -96,6 +88,20 @@ def exit_with_error(msg):
|
||||||
raise ConnectionError()
|
raise ConnectionError()
|
||||||
|
|
||||||
|
|
||||||
|
def get_conn_error_message(url):
|
||||||
|
if call_silently(['which', 'docker']) != 0:
|
||||||
|
if is_mac():
|
||||||
|
return docker_not_found_mac
|
||||||
|
if is_ubuntu():
|
||||||
|
return docker_not_found_ubuntu
|
||||||
|
return docker_not_found_generic
|
||||||
|
if is_docker_for_mac_installed():
|
||||||
|
return conn_error_docker_for_mac
|
||||||
|
if call_silently(['which', 'docker-machine']) == 0:
|
||||||
|
return conn_error_docker_machine
|
||||||
|
return conn_error_generic.format(url=url)
|
||||||
|
|
||||||
|
|
||||||
docker_not_found_mac = """
|
docker_not_found_mac = """
|
||||||
Couldn't connect to Docker daemon. You might need to install Docker:
|
Couldn't connect to Docker daemon. You might need to install Docker:
|
||||||
|
|
||||||
|
@ -121,6 +127,10 @@ conn_error_docker_machine = """
|
||||||
Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
|
Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
conn_error_docker_for_mac = """
|
||||||
|
Couldn't connect to Docker daemon. You might need to start Docker for Mac.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
conn_error_generic = """
|
conn_error_generic = """
|
||||||
Couldn't connect to Docker daemon at {url} - is it running?
|
Couldn't connect to Docker daemon at {url} - is it running?
|
||||||
|
|
|
@ -103,3 +103,7 @@ def get_build_version():
|
||||||
|
|
||||||
with open(filename) as fh:
|
with open(filename) as fh:
|
||||||
return fh.read().strip()
|
return fh.read().strip()
|
||||||
|
|
||||||
|
|
||||||
|
def is_docker_for_mac_installed():
|
||||||
|
return is_mac() and os.path.isdir('/Applications/Docker.app')
|
||||||
|
|
Loading…
Reference in New Issue