File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ def parse_host(addr):
232
232
proto = "http+unix"
233
233
host = DEFAULT_HTTP_HOST
234
234
port = None
235
+ path = ''
235
236
if not addr or addr .strip () == 'unix://' :
236
237
return DEFAULT_UNIX_SOCKET
237
238
@@ -270,8 +271,12 @@ def parse_host(addr):
270
271
if host_parts [0 ]:
271
272
host = host_parts [0 ]
272
273
274
+ port = host_parts [1 ]
275
+ if '/' in port :
276
+ port , path = port .split ('/' , 1 )
277
+ path = '/{0}' .format (path )
273
278
try :
274
- port = int (host_parts [ 1 ] )
279
+ port = int (port )
275
280
except Exception :
276
281
raise errors .DockerException (
277
282
"Invalid port: %s" , addr
@@ -285,7 +290,7 @@ def parse_host(addr):
285
290
286
291
if proto == "http+unix" :
287
292
return "{0}://{1}" .format (proto , host )
288
- return "{0}://{1}:{2}" .format (proto , host , port )
293
+ return "{0}://{1}:{2}{3} " .format (proto , host , port , path )
289
294
290
295
291
296
def parse_devices (devices ):
Original file line number Diff line number Diff line change @@ -72,7 +72,10 @@ def test_parse_host(self):
72
72
'' : 'http+unix://var/run/docker.sock' ,
73
73
None : 'http+unix://var/run/docker.sock' ,
74
74
'unix:///var/run/docker.sock' : 'http+unix:///var/run/docker.sock' ,
75
- 'unix://' : 'http+unix://var/run/docker.sock'
75
+ 'unix://' : 'http+unix://var/run/docker.sock' ,
76
+ 'somehost.net:80/service/swarm' : (
77
+ 'http://somehost.net:80/service/swarm'
78
+ ),
76
79
}
77
80
78
81
for host in invalid_hosts :
You can’t perform that action at this time.
0 commit comments