|
|
@@ -1,6 +1,7 @@
|
|
|
from __future__ import unicode_literals
|
|
|
from __future__ import absolute_import
|
|
|
from ..packages.docker import Client
|
|
|
+from requests.exceptions import ConnectionError
|
|
|
import errno
|
|
|
import logging
|
|
|
import os
|
|
|
@@ -11,12 +12,23 @@ from ..project import Project
|
|
|
from .docopt_command import DocoptCommand
|
|
|
from .formatter import Formatter
|
|
|
from .utils import cached_property, docker_url
|
|
|
+from .errors import UserError
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class Command(DocoptCommand):
|
|
|
base_dir = '.'
|
|
|
|
|
|
+ def dispatch(self, *args, **kwargs):
|
|
|
+ try:
|
|
|
+ super(Command, self).dispatch(*args, **kwargs)
|
|
|
+ except ConnectionError:
|
|
|
+ raise UserError("""
|
|
|
+Couldn't connect to Docker daemon at %s - is it running?
|
|
|
+
|
|
|
+If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
|
|
|
+""" % self.client.base_url)
|
|
|
+
|
|
|
@cached_property
|
|
|
def client(self):
|
|
|
return Client(docker_url())
|