|
@@ -15,6 +15,7 @@ from requests.packages.urllib3.exceptions import ReadTimeoutError
|
|
|
from ..const import API_VERSION_TO_ENGINE_VERSION
|
|
|
from ..const import HTTP_TIMEOUT
|
|
|
from .utils import call_silently
|
|
|
+from .utils import is_docker_for_mac_installed
|
|
|
from .utils import is_mac
|
|
|
from .utils import is_ubuntu
|
|
|
|
|
@@ -48,16 +49,7 @@ def handle_connection_errors(client):
|
|
|
if e.args and isinstance(e.args[0], ReadTimeoutError):
|
|
|
log_timeout_error()
|
|
|
raise ConnectionError()
|
|
|
-
|
|
|
- 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))
|
|
|
+ exit_with_error(get_conn_error_message(client.base_url))
|
|
|
except APIError as e:
|
|
|
log_api_error(e, client.api_version)
|
|
|
raise ConnectionError()
|
|
@@ -97,6 +89,20 @@ def exit_with_error(msg):
|
|
|
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 = """
|
|
|
Couldn't connect to Docker daemon. You might need to install Docker:
|
|
|
|
|
@@ -122,6 +128,10 @@ conn_error_docker_machine = """
|
|
|
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 = """
|
|
|
Couldn't connect to Docker daemon at {url} - is it running?
|