File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 14
14
import urllib
15
15
import docker
16
16
from docker .models .containers import Container
17
+ from docker .transport import UnixHTTPAdapter
17
18
from testcontainers .core .utils import inside_container
18
19
from testcontainers .core .utils import default_gateway_ip
19
20
@@ -72,11 +73,14 @@ def host(self):
72
73
73
74
except ValueError :
74
75
return None
76
+ adapter = self .client .api .get_adapter (self .client .api .base_url )
77
+ is_ipc = isinstance (adapter , UnixHTTPAdapter )
78
+ is_ipc |= hasattr (adapter , "socket_path" ) or hasattr (adapter , "npipe_path" )
79
+ is_ipc |= 'unix' in url .scheme or 'npipe' in url .scheme
80
+ if is_ipc and inside_container ():
81
+ ip_address = default_gateway_ip ()
82
+ if ip_address :
83
+ return ip_address
75
84
if 'http' in url .scheme or 'tcp' in url .scheme :
76
85
return url .hostname
77
- if 'unix' in url .scheme or 'npipe' in url .scheme :
78
- if inside_container ():
79
- ip_address = default_gateway_ip ()
80
- if ip_address :
81
- return ip_address
82
86
return "localhost"
You can’t perform that action at this time.
0 commit comments