-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create client from current docker context #2616
Comments
I've just been looking to do this - and I can't find that Contexts are usable in any way, other than to inspect/create/delete them... |
It world be better to two related changes: client = docker.ContextAPI().get_context('context-name').get_client() And |
Here's a workaround if you use current_ctx = docker.context.Context.load_context(docker.context.api.get_current_context_name())
url = current_ctx.endpoints["docker"]["Host"]
client = docker.DockerClient(base_url=url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As we are using swarm on remote servers, using docker CLI we take advantage of
docker context
.My expectation was, that the
docker
library will behave similarly to CLI thus created client would respect currently configured docker context. This does not seem to be the case.Anyway, it would be great to have some simple method, which would create client based on current docker context, e.g.:
The text was updated successfully, but these errors were encountered: