Get a tarball of an image. Similar to the ``docker save`` command. Args: image (str): Image name to get chunk_size (int): The number of bytes returned by each iteration of the generator. If ``None``, data will be streamed as it is
(self, image, chunk_size=DEFAULT_DATA_CHUNK_SIZE)
| 11 | |
| 12 | @utils.check_resource('image') |
| 13 | def get_image(self, image, chunk_size=DEFAULT_DATA_CHUNK_SIZE): |
| 14 | """ |
| 15 | Get a tarball of an image. Similar to the ``docker save`` command. |
| 16 | |
| 17 | Args: |
| 18 | image (str): Image name to get |
| 19 | chunk_size (int): The number of bytes returned by each iteration |
| 20 | of the generator. If ``None``, data will be streamed as it is |
| 21 | received. Default: 2 MB |
| 22 | |
| 23 | Returns: |
| 24 | (generator): A stream of raw archive data. |
| 25 | |
| 26 | Raises: |
| 27 | :py:class:`docker.errors.APIError` |
| 28 | If the server returns an error. |
| 29 | |
| 30 | Example: |
| 31 | |
| 32 | >>> image = client.api.get_image("busybox:latest") |
| 33 | >>> f = open('/tmp/busybox-latest.tar', 'wb') |
| 34 | >>> for chunk in image: |
| 35 | >>> f.write(chunk) |
| 36 | >>> f.close() |
| 37 | """ |
| 38 | res = self._get(self._url("/images/{0}/get", image), stream=True) |
| 39 | return self._stream_raw_result(res, chunk_size, False) |
| 40 | |
| 41 | @utils.check_resource('image') |
| 42 | def history(self, image): |