diff --git a/botocore/utils.py b/botocore/utils.py index 9553e0c82a..f592b4a451 100644 --- a/botocore/utils.py +++ b/botocore/utils.py @@ -3075,6 +3075,7 @@ class ContainerMetadataFetcher: '169.254.170.23', 'fd00:ec2::23', 'localhost', + 'host.docker.internal', ] def __init__(self, session=None, sleep=time.sleep): diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 702fb16515..506e030e1b 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -2775,6 +2775,11 @@ def test_localhost_http_is_allowed(self): def test_localhost_with_port_http_is_allowed(self): self.assert_can_retrieve_metadata_from('http://localhost:8000/foo') + def test_docker_host_http_is_allowed(self): + self.assert_can_retrieve_metadata_from( + 'http://host.docker.internal/foo' + ) + def test_localhost_https_is_allowed(self): self.assert_can_retrieve_metadata_from('https://localhost/foo')