File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 14
14
RYUK_DISABLED : bool = environ .get ("TESTCONTAINERS_RYUK_DISABLED" , "false" ) == "true"
15
15
RYUK_DOCKER_SOCKET : str = environ .get ("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE" , "/var/run/docker.sock" )
16
16
RYUK_RECONNECTION_TIMEOUT : str = environ .get ("RYUK_RECONNECTION_TIMEOUT" , "10s" )
17
+ TC_HOST_OVERRIDE : Optional [str ] = environ .get ("TC_HOST" , environ .get ("TESTCONTAINERS_HOST_OVERRIDE" ))
17
18
18
19
TC_FILE = ".testcontainers.properties"
19
20
TC_GLOBAL = Path .home () / TC_FILE
@@ -52,6 +53,11 @@ class TestcontainersConfiguration:
52
53
ryuk_reconnection_timeout : str = RYUK_RECONNECTION_TIMEOUT
53
54
tc_properties : dict [str , str ] = field (default_factory = read_tc_properties )
54
55
_docker_auth_config : Optional [str ] = field (default_factory = lambda : environ .get ("DOCKER_AUTH_CONFIG" ))
56
+ tc_host_override : Optional [str ] = TC_HOST_OVERRIDE
57
+ """
58
+ https://github.com/testcontainers/testcontainers-go/blob/dd76d1e39c654433a3d80429690d07abcec04424/docker.go#L644
59
+ if os env TC_HOST is set, use it
60
+ """
55
61
56
62
@property
57
63
def docker_auth_config (self ):
Original file line number Diff line number Diff line change @@ -187,18 +187,14 @@ def host(self) -> str:
187
187
"""
188
188
Get the hostname or ip address of the docker host.
189
189
"""
190
- # https://github.com/testcontainers/testcontainers-go/blob/dd76d1e39c654433a3d80429690d07abcec04424/docker.go#L644
191
- # if os env TC_HOST is set, use it
192
- host = os .environ .get ("TC_HOST" )
193
- if not host :
194
- host = os .environ .get ("TESTCONTAINERS_HOST_OVERRIDE" )
190
+ host = c .tc_host_override
195
191
if host :
196
192
return host
197
193
try :
198
194
url = urllib .parse .urlparse (self .client .api .base_url )
199
195
200
196
except ValueError :
201
- return None
197
+ return "localhost"
202
198
if "http" in url .scheme or "tcp" in url .scheme :
203
199
return url .hostname
204
200
if inside_container () and ("unix" in url .scheme or "npipe" in url .scheme ):
You can’t perform that action at this time.
0 commit comments