Skip to content

Commit 570693c

Browse files
committed
Allow docker host (base_url) to contain a path
1 parent 139850f commit 570693c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docker/utils/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def parse_host(addr):
232232
proto = "http+unix"
233233
host = DEFAULT_HTTP_HOST
234234
port = None
235+
path = ''
235236
if not addr or addr.strip() == 'unix://':
236237
return DEFAULT_UNIX_SOCKET
237238

@@ -270,8 +271,12 @@ def parse_host(addr):
270271
if host_parts[0]:
271272
host = host_parts[0]
272273

274+
port = host_parts[1]
275+
if '/' in port:
276+
port, path = port.split('/', 1)
277+
path = '/{0}'.format(path)
273278
try:
274-
port = int(host_parts[1])
279+
port = int(port)
275280
except Exception:
276281
raise errors.DockerException(
277282
"Invalid port: %s", addr
@@ -285,7 +290,7 @@ def parse_host(addr):
285290

286291
if proto == "http+unix":
287292
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)
289294

290295

291296
def parse_devices(devices):

0 commit comments

Comments
 (0)