File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 14
14
import docker
15
15
from docker .errors import NotFound
16
16
from docker .models .containers import Container , ContainerCollection
17
+ from docker .transport import UnixHTTPAdapter
17
18
import functools as ft
18
19
import os
19
20
from typing import List , Optional , Union
@@ -102,11 +103,14 @@ def host(self) -> str:
102
103
103
104
except ValueError :
104
105
return None
106
+ adapter = self .client .api .get_adapter (self .client .api .base_url )
107
+ is_ipc = isinstance (adapter , UnixHTTPAdapter )
108
+ is_ipc |= hasattr (adapter , "socket_path" ) or hasattr (adapter , "npipe_path" )
109
+ is_ipc |= 'unix' in url .scheme or 'npipe' in url .scheme
110
+ if is_ipc and inside_container ():
111
+ ip_address = default_gateway_ip ()
112
+ if ip_address :
113
+ return ip_address
105
114
if 'http' in url .scheme or 'tcp' in url .scheme :
106
115
return url .hostname
107
- if 'unix' in url .scheme or 'npipe' in url .scheme :
108
- if inside_container ():
109
- ip_address = default_gateway_ip ()
110
- if ip_address :
111
- return ip_address
112
116
return "localhost"
You can’t perform that action at this time.
0 commit comments