Pulls an image. Similar to the ``docker pull`` command. Args: repository (str): The repository to pull tag (str): The tag to pull. If ``tag`` is ``None`` or empty, it is set to ``latest``. stream (bool): Stream the output as a gen
(self, repository, tag=None, stream=False, auth_config=None,
decode=False, platform=None, all_tags=False)
| 349 | return self._result(self._post(url, params=params), True) |
| 350 | |
| 351 | def pull(self, repository, tag=None, stream=False, auth_config=None, |
| 352 | decode=False, platform=None, all_tags=False): |
| 353 | """ |
| 354 | Pulls an image. Similar to the ``docker pull`` command. |
| 355 | |
| 356 | Args: |
| 357 | repository (str): The repository to pull |
| 358 | tag (str): The tag to pull. If ``tag`` is ``None`` or empty, it |
| 359 | is set to ``latest``. |
| 360 | stream (bool): Stream the output as a generator. Make sure to |
| 361 | consume the generator, otherwise pull might get cancelled. |
| 362 | auth_config (dict): Override the credentials that are found in the |
| 363 | config for this request. ``auth_config`` should contain the |
| 364 | ``username`` and ``password`` keys to be valid. |
| 365 | decode (bool): Decode the JSON data from the server into dicts. |
| 366 | Only applies with ``stream=True`` |
| 367 | platform (str): Platform in the format ``os[/arch[/variant]]`` |
| 368 | all_tags (bool): Pull all image tags, the ``tag`` parameter is |
| 369 | ignored. |
| 370 | |
| 371 | Returns: |
| 372 | (generator or str): The output |
| 373 | |
| 374 | Raises: |
| 375 | :py:class:`docker.errors.APIError` |
| 376 | If the server returns an error. |
| 377 | |
| 378 | Example: |
| 379 | |
| 380 | >>> resp = client.api.pull('busybox', stream=True, decode=True) |
| 381 | ... for line in resp: |
| 382 | ... print(json.dumps(line, indent=4)) |
| 383 | { |
| 384 | "status": "Pulling image (latest) from busybox", |
| 385 | "progressDetail": {}, |
| 386 | "id": "e72ac664f4f0" |
| 387 | } |
| 388 | { |
| 389 | "status": "Pulling image (latest) from busybox, endpoint: ...", |
| 390 | "progressDetail": {}, |
| 391 | "id": "e72ac664f4f0" |
| 392 | } |
| 393 | |
| 394 | """ |
| 395 | repository, image_tag = utils.parse_repository_tag(repository) |
| 396 | tag = tag or image_tag or 'latest' |
| 397 | |
| 398 | if all_tags: |
| 399 | tag = None |
| 400 | |
| 401 | registry, repo_name = auth.resolve_repository_name(repository) |
| 402 | |
| 403 | params = { |
| 404 | 'tag': tag, |
| 405 | 'fromImage': repository |
| 406 | } |
| 407 | headers = {} |
| 408 |