summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/api/container.py7
-rw-r--r--docker/api/image.py13
-rw-r--r--docker/models/images.py12
3 files changed, 14 insertions, 18 deletions
diff --git a/docker/api/container.py b/docker/api/container.py
index b08032c..49230c7 100644
--- a/docker/api/container.py
+++ b/docker/api/container.py
@@ -698,7 +698,7 @@ class ContainerApiMixin(object):
container (str): The container to export
Returns:
- (str): The filesystem tar archive
+ (generator): The archived filesystem data stream
Raises:
:py:class:`docker.errors.APIError`
@@ -707,8 +707,7 @@ class ContainerApiMixin(object):
res = self._get(
self._url("/containers/{0}/export", container), stream=True
)
- self._raise_for_status(res)
- return res.raw
+ return self._stream_raw_result(res)
@utils.check_resource('container')
@utils.minimum_version('1.20')
@@ -737,7 +736,7 @@ class ContainerApiMixin(object):
self._raise_for_status(res)
encoded_stat = res.headers.get('x-docker-container-path-stat')
return (
- res.raw,
+ self._stream_raw_result(res),
utils.decode_json_header(encoded_stat) if encoded_stat else None
)
diff --git a/docker/api/image.py b/docker/api/image.py
index 065fae3..b3dcd3a 100644
--- a/docker/api/image.py
+++ b/docker/api/image.py
@@ -21,8 +21,7 @@ class ImageApiMixin(object):
image (str): Image name to get
Returns:
- (urllib3.response.HTTPResponse object): The response from the
- daemon.
+ (generator): A stream of raw archive data.
Raises:
:py:class:`docker.errors.APIError`
@@ -30,14 +29,14 @@ class ImageApiMixin(object):
Example:
- >>> image = cli.get_image("fedora:latest")
- >>> f = open('/tmp/fedora-latest.tar', 'w')
- >>> f.write(image.data)
+ >>> image = cli.get_image("busybox:latest")
+ >>> f = open('/tmp/busybox-latest.tar', 'w')
+ >>> for chunk in image:
+ >>> f.write(chunk)
>>> f.close()
"""
res = self._get(self._url("/images/{0}/get", image), stream=True)
- self._raise_for_status(res)
- return res.raw
+ return self._stream_raw_result(res)
@utils.check_resource('image')
def history(self, image):
diff --git a/docker/models/images.py b/docker/models/images.py
index dcdeac9..8229cfc 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -61,8 +61,7 @@ class Image(Model):
Get a tarball of an image. Similar to the ``docker save`` command.
Returns:
- (urllib3.response.HTTPResponse object): The response from the
- daemon.
+ (generator): A stream of raw archive data.
Raises:
:py:class:`docker.errors.APIError`
@@ -70,11 +69,10 @@ class Image(Model):
Example:
- >>> image = cli.images.get("fedora:latest")
- >>> resp = image.save()
- >>> f = open('/tmp/fedora-latest.tar', 'w')
- >>> for chunk in resp.stream():
- >>> f.write(chunk)
+ >>> image = cli.get_image("busybox:latest")
+ >>> f = open('/tmp/busybox-latest.tar', 'w')
+ >>> for chunk in image:
+ >>> f.write(chunk)
>>> f.close()
"""
return self.client.api.get_image(self.id)