This commit is contained in:
Thomas Grainger 2025-01-23 10:18:26 +00:00 committed by GitHub
commit 0660f9e3ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -20,7 +20,8 @@ class DockerClient:
Example:
>>> import docker
>>> client = docker.DockerClient(base_url='unix://var/run/docker.sock')
>>> with docker.DockerClient(base_url='unix://var/run/docker.sock') as client:
...
Args:
base_url (str): URL to the Docker server. For example,
@ -209,6 +210,16 @@ class DockerClient:
return self.api.close()
close.__doc__ = APIClient.close.__doc__
def __enter__(self):
self.api.__enter__()
return self
__enter__.__doc__ = APIClient.__enter__.__doc__
def __exit__(self, *args, **kwargs):
return self.api.__exit__(*args, **kwargs)
__exit__.__doc__ = APIClient.__exit__.__doc__
def __getattr__(self, name):
s = [f"'DockerClient' object has no attribute '{name}'"]
# If a user calls a method on APIClient, they