diff options
Diffstat (limited to 'docker/api')
-rw-r--r-- | docker/api/container.py | 7 | ||||
-rw-r--r-- | docker/api/image.py | 13 |
2 files changed, 9 insertions, 11 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): |