diff --git a/samcli/local/docker/container.py b/samcli/local/docker/container.py index 97e7a8613e..75174d58cc 100644 --- a/samcli/local/docker/container.py +++ b/samcli/local/docker/container.py @@ -99,7 +99,9 @@ def create(self): } }, # We are not running an interactive shell here. - "tty": False + "tty": False, + # Set proxy configuration from global Docker config file + "use_config_proxy": True } if self._container_opts: diff --git a/samcli/local/docker/utils.py b/samcli/local/docker/utils.py index 44ece9d68d..3e1379fd80 100644 --- a/samcli/local/docker/utils.py +++ b/samcli/local/docker/utils.py @@ -3,8 +3,8 @@ """ import os -import posixpath import re +import posixpath try: import pathlib except ImportError: diff --git a/tests/unit/local/docker/test_container.py b/tests/unit/local/docker/test_container.py index 19ff4033e2..2b8fe440b7 100644 --- a/tests/unit/local/docker/test_container.py +++ b/tests/unit/local/docker/test_container.py @@ -97,7 +97,8 @@ def test_must_create_container_with_required_values(self): command=self.cmd, working_dir=self.working_dir, volumes=expected_volumes, - tty=False) + tty=False, + use_config_proxy=True) self.mock_docker_client.networks.get.assert_not_called() def test_must_create_container_including_all_optional_values(self): @@ -141,6 +142,7 @@ def test_must_create_container_including_all_optional_values(self): working_dir=self.working_dir, volumes=expected_volumes, tty=False, + use_config_proxy=True, environment=self.env_vars, ports=self.exposed_ports, entrypoint=self.entrypoint, @@ -206,6 +208,7 @@ def test_must_create_container_translate_volume_path(self, os_mock): working_dir=self.working_dir, volumes=translated_volumes, tty=False, + use_config_proxy=True, environment=self.env_vars, ports=self.exposed_ports, entrypoint=self.entrypoint, @@ -250,6 +253,7 @@ def test_must_connect_to_network_on_create(self): command=self.cmd, working_dir=self.working_dir, tty=False, + use_config_proxy=True, volumes=expected_volumes ) @@ -292,6 +296,7 @@ def test_must_connect_to_host_network_on_create(self): command=self.cmd, working_dir=self.working_dir, tty=False, + use_config_proxy=True, volumes=expected_volumes, network_mode='host' )