mirror of https://github.com/docker/compose.git
Handle connection errors on project initialization
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
6ce066274e
commit
b3a4d76d4f
|
@ -8,6 +8,7 @@ import ssl
|
|||
|
||||
import six
|
||||
|
||||
from . import errors
|
||||
from . import verbose_proxy
|
||||
from .. import config
|
||||
from ..config.environment import Environment
|
||||
|
@ -110,7 +111,8 @@ def get_project(project_dir, config_path=None, project_name=None, verbose=False,
|
|||
host=host, environment=environment
|
||||
)
|
||||
|
||||
return Project.from_config(project_name, config_data, client)
|
||||
with errors.handle_connection_errors(client):
|
||||
return Project.from_config(project_name, config_data, client)
|
||||
|
||||
|
||||
def get_project_name(working_dir, project_name=None, environment=None):
|
||||
|
|
|
@ -154,6 +154,19 @@ class CLITestCase(DockerClientTestCase):
|
|||
returncode=0
|
||||
)
|
||||
|
||||
def test_host_not_reachable(self):
|
||||
result = self.dispatch(['-H=tcp://doesnotexist:8000', 'ps'], returncode=1)
|
||||
assert "Couldn't connect to Docker daemon" in result.stderr
|
||||
|
||||
def test_host_not_reachable_volumes_from_container(self):
|
||||
self.base_dir = 'tests/fixtures/volumes-from-container'
|
||||
|
||||
container = self.client.create_container('busybox', 'true', name='composetest_data_container')
|
||||
self.addCleanup(self.client.remove_container, container)
|
||||
|
||||
result = self.dispatch(['-H=tcp://doesnotexist:8000', 'ps'], returncode=1)
|
||||
assert "Couldn't connect to Docker daemon" in result.stderr
|
||||
|
||||
def test_config_list_services(self):
|
||||
self.base_dir = 'tests/fixtures/v2-full'
|
||||
result = self.dispatch(['config', '--services'])
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
version: "2"
|
||||
services:
|
||||
test:
|
||||
image: busybox
|
||||
volumes_from: ["container:composetest_data_container"]
|
Loading…
Reference in New Issue