Skip to content

Commit 1dbbea6

Browse files
committed
Use localhost rather than 0.0.0.0 (fixes #38).
1 parent 1d28e14 commit 1dbbea6

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

testcontainers/core/container.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from testcontainers.core.docker_client import DockerClient
66
from testcontainers.core.exceptions import ContainerStartException
7-
from testcontainers.core.utils import is_windows, inside_container
7+
from testcontainers.core.utils import inside_container
88

99

1010
class DockerContainer(object):
@@ -81,10 +81,7 @@ def get_container_host_ip(self) -> str:
8181
# container's IP address from the dockder "bridge" network
8282
if inside_container():
8383
return self.get_docker_client().bridge_ip(self._container.id)
84-
elif is_windows():
85-
return "localhost"
86-
else:
87-
return "0.0.0.0"
84+
return "localhost"
8885

8986
def get_exposed_port(self, port) -> str:
9087
if inside_container():

tests/test_new_docker_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_docker_env_variables():
3030
db.with_bind_ports(3306, 32785)
3131
with db:
3232
url = db.get_connection_url()
33-
assert url == 'mysql+pymysql://demo:test@0.0.0.0:32785/custom_db'
33+
assert url == 'mysql+pymysql://demo:test@localhost:32785/custom_db'
3434

3535

3636
def test_docker_kargs():

0 commit comments

Comments
 (0)