diff options
| author | Joffrey F <joffrey@docker.com> | 2015-08-17 14:36:19 -0700 |
|---|---|---|
| committer | Joffrey F <joffrey@docker.com> | 2015-08-17 14:36:19 -0700 |
| commit | 570693c81023316430db79c1cc7f75cfd2284844 (patch) | |
| tree | 50c51e9462645a1697a261ee5832b0ca36a1d416 /docker/utils/utils.py | |
| parent | 139850f3f3b17357bab5ba3edfb745fb14043764 (diff) | |
| download | docker-py-570693c81023316430db79c1cc7f75cfd2284844.tar.gz | |
Allow docker host (base_url) to contain a path
Diffstat (limited to 'docker/utils/utils.py')
| -rw-r--r-- | docker/utils/utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py index d979c96..8ac38e3 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -232,6 +232,7 @@ def parse_host(addr): proto = "http+unix" host = DEFAULT_HTTP_HOST port = None + path = '' if not addr or addr.strip() == 'unix://': return DEFAULT_UNIX_SOCKET @@ -270,8 +271,12 @@ def parse_host(addr): if host_parts[0]: host = host_parts[0] + port = host_parts[1] + if '/' in port: + port, path = port.split('/', 1) + path = '/{0}'.format(path) try: - port = int(host_parts[1]) + port = int(port) except Exception: raise errors.DockerException( "Invalid port: %s", addr @@ -285,7 +290,7 @@ def parse_host(addr): if proto == "http+unix": return "{0}://{1}".format(proto, host) - return "{0}://{1}:{2}".format(proto, host, port) + return "{0}://{1}:{2}{3}".format(proto, host, port, path) def parse_devices(devices): |
