Skip to content

Commit a34dd8b

Browse files
committed
Fix images low-level documentation examples
I realize that the documentation of low-level `images` was outdated when answering issue #2798 The issue can reproduce it with a simple test: ```py In [1]: import docker In [2]: client = docker.from_env() In [3]: client.pull --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-3-d0931943ca5d> in <module> ----> 1 client.pull ~/docker-py/docker/client.py in __getattr__(self, name) 219 "object APIClient. See the low-level API section of the " 220 "documentation for more details.") --> 221 raise AttributeError(' '.join(s)) 222 223 AttributeError: 'DockerClient' object has no attribute 'pull' In Docker SDK for Python 2.0, this method is now on the object APIClient. See the low-level API section of the documentation for more details. In [4]: client.push --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-4-f7d5b860a184> in <module> ----> 1 client.push ~/docker-py/docker/client.py in __getattr__(self, name) 219 "object APIClient. See the low-level API section of the " 220 "documentation for more details.") --> 221 raise AttributeError(' '.join(s)) 222 223 AttributeError: 'DockerClient' object has no attribute 'push' In Docker SDK for Python 2.0, this method is now on the object APIClient. See the low-level API section of the documentation for more details. In [5]: client.tag --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-5-043bdfd088ca> in <module> ----> 1 client.tag ~/docker-py/docker/client.py in __getattr__(self, name) 219 "object APIClient. See the low-level API section of the " 220 "documentation for more details.") --> 221 raise AttributeError(' '.join(s)) 222 223 AttributeError: 'DockerClient' object has no attribute 'tag' In Docker SDK for Python 2.0, this method is now on the object APIClient. See the low-level API section of the documentation for more details. In [6]: client.get_image --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-6-477c12713276> in <module> ----> 1 client.get_image ~/docker-py/docker/client.py in __getattr__(self, name) 219 "object APIClient. See the low-level API section of the " 220 "documentation for more details.") --> 221 raise AttributeError(' '.join(s)) 222 223 AttributeError: 'DockerClient' object has no attribute 'get_image' In Docker SDK for Python 2.0, this method is now on the object APIClient. See the low-level API section of the documentation for more details. In [7]: client.api.get_image Out[7]: <bound method ImageApiMixin.get_image of <docker.api.client.APIClient object at 0x7fad6a2037c0>> In [8]: client.api.tag Out[8]: <bound method ImageApiMixin.tag of <docker.api.client.APIClient object at 0x7fad6a2037c0>> In [9]: client.api.pull Out[9]: <bound method ImageApiMixin.pull of <docker.api.client.APIClient object at 0x7fad6a2037c0>> In [10]: client.api.push Out[10]: <bound method ImageApiMixin.push of <docker.api.client.APIClient object at 0x7fad6a2037c0>> ``` Signed-off-by: Felipe Ruhland <[email protected]>
1 parent 0892fcf commit a34dd8b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docker/api/image.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_image(self, image, chunk_size=DEFAULT_DATA_CHUNK_SIZE):
3131
3232
Example:
3333
34-
>>> image = cli.get_image("busybox:latest")
34+
>>> image = client.api.get_image("busybox:latest")
3535
>>> f = open('/tmp/busybox-latest.tar', 'wb')
3636
>>> for chunk in image:
3737
>>> f.write(chunk)
@@ -379,7 +379,7 @@ def pull(self, repository, tag=None, stream=False, auth_config=None,
379379
380380
Example:
381381
382-
>>> for line in cli.pull('busybox', stream=True, decode=True):
382+
>>> for line in client.api.pull('busybox', stream=True, decode=True):
383383
... print(json.dumps(line, indent=4))
384384
{
385385
"status": "Pulling image (latest) from busybox",
@@ -458,7 +458,7 @@ def push(self, repository, tag=None, stream=False, auth_config=None,
458458
If the server returns an error.
459459
460460
Example:
461-
>>> for line in cli.push('yourname/app', stream=True, decode=True):
461+
>>> for line in client.api.push('yourname/app', stream=True, decode=True):
462462
... print(line)
463463
{'status': 'Pushing repository yourname/app (1 tags)'}
464464
{'status': 'Pushing','progressDetail': {}, 'id': '511136ea3c5a'}
@@ -549,7 +549,7 @@ def tag(self, image, repository, tag=None, force=False):
549549
550550
Example:
551551
552-
>>> client.tag('ubuntu', 'localhost:5000/ubuntu', 'latest',
552+
>>> client.api.tag('ubuntu', 'localhost:5000/ubuntu', 'latest',
553553
force=True)
554554
"""
555555
params = {

0 commit comments

Comments
 (0)