Skip to content

Commit a8ae17b

Browse files
ale-cciale-corradi
authored andcommitted
fix: Use Host provided by default context if no host is provided.
Related to issue: #3146 Signed-off-by: Alessandro Corradi <corradi.alessandro@mmfg.it>
1 parent df3f8e2 commit a8ae17b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

docker/api/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
MINIMUM_DOCKER_API_VERSION,
1919
STREAM_HEADER_SIZE_BYTES,
2020
)
21+
from .. import context
2122
from ..errors import (
2223
DockerException,
2324
InvalidVersion,
@@ -124,6 +125,11 @@ def __init__(self, base_url=None, version=None,
124125
'If using TLS, the base_url argument must be provided.'
125126
)
126127

128+
if base_url is None:
129+
current_ctx = context.ContextAPI.get_current_context()
130+
if current_ctx is not None:
131+
base_url = current_ctx.Host
132+
127133
self.base_url = base_url
128134
self.timeout = timeout
129135
self.headers['User-Agent'] = user_agent

0 commit comments

Comments
 (0)