diff --git a/compose/cli/main.py b/compose/cli/main.py index 9e49e2974..c05ba4988 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -1418,7 +1418,7 @@ def call_docker(args, dockeropts): if verify: tls_options.append('--tlsverify') if host: - tls_options.extend(['--host', host]) + tls_options.extend(['--host', host.lstrip('=')]) args = [executable_path] + tls_options + args log.debug(" ".join(map(pipes.quote, args))) diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 14c96b24d..075705804 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -177,6 +177,13 @@ class CLITestCase(DockerClientTestCase): returncode=0 ) + def test_shorthand_host_opt_interactive(self): + self.dispatch( + ['-H={0}'.format(os.environ.get('DOCKER_HOST', 'unix://')), + 'run', 'another', 'ls'], + 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 diff --git a/tests/unit/cli/main_test.py b/tests/unit/cli/main_test.py index b46a3ee22..1a2dfbcf3 100644 --- a/tests/unit/cli/main_test.py +++ b/tests/unit/cli/main_test.py @@ -154,3 +154,11 @@ class TestCallDocker(object): assert fake_call.call_args[0][0] == [ 'docker', '--host', 'tcp://mydocker.net:2333', 'ps' ] + + def test_with_host_option_shorthand_equal(self): + with mock.patch('subprocess.call') as fake_call: + call_docker(['ps'], {'--host': '=tcp://mydocker.net:2333'}) + + assert fake_call.call_args[0][0] == [ + 'docker', '--host', 'tcp://mydocker.net:2333', 'ps' + ]