Use DOCKER_HOST environment variable to find Docker daemon
Removed all "smart" connection logic. Fig either uses the DOCKER_HOST environment variable if it's present, or passes `None` to docker-py, which does the "right thing" (i.e. falls back to the Unix socket). This means we no longer know at URL-deciding time whether we can connect to the Docker daemon, so we wrap `dispatch` in a `try/except` which catches `requests.exceptions.ConnectionError`.
This commit is contained in:
parent
f36dd414a0
commit
3e2fd6a2a1
2 changed files with 13 additions and 30 deletions
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue