MCPcopy
hub / github.com/docker/docker-py / push

Method push

docker/api/image.py:436–500  ·  view source on GitHub ↗

Push an image or a repository to the registry. Similar to the ``docker push`` command. Args: repository (str): The repository to push to tag (str): An optional tag to push stream (bool): Stream the output as a blocking generator

(self, repository, tag=None, stream=False, auth_config=None,
             decode=False)

Source from the content-addressed store, hash-verified

434 return self._result(response)
435
436 def push(self, repository, tag=None, stream=False, auth_config=None,
437 decode=False):
438 """
439 Push an image or a repository to the registry. Similar to the ``docker
440 push`` command.
441
442 Args:
443 repository (str): The repository to push to
444 tag (str): An optional tag to push
445 stream (bool): Stream the output as a blocking generator
446 auth_config (dict): Override the credentials that are found in the
447 config for this request. ``auth_config`` should contain the
448 ``username`` and ``password`` keys to be valid.
449 decode (bool): Decode the JSON data from the server into dicts.
450 Only applies with ``stream=True``
451
452 Returns:
453 (generator or str): The output from the server.
454
455 Raises:
456 :py:class:`docker.errors.APIError`
457 If the server returns an error.
458
459 Example:
460 >>> resp = client.api.push(
461 ... 'yourname/app',
462 ... stream=True,
463 ... decode=True,
464 ... )
465 ... for line in resp:
466 ... print(line)
467 {'status': 'Pushing repository yourname/app (1 tags)'}
468 {'status': 'Pushing','progressDetail': {}, 'id': '511136ea3c5a'}
469 {'status': 'Image already pushed, skipping', 'progressDetail':{},
470 'id': '511136ea3c5a'}
471 ...
472
473 """
474 if not tag:
475 repository, tag = utils.parse_repository_tag(repository)
476 registry, repo_name = auth.resolve_repository_name(repository)
477 u = self._url("/images/{0}/push", repository)
478 params = {
479 'tag': tag
480 }
481 headers = {}
482
483 if auth_config is None:
484 header = auth.get_config_header(self, registry)
485 if header:
486 headers['X-Registry-Auth'] = header
487 else:
488 log.debug('Sending supplied auth config')
489 headers['X-Registry-Auth'] = auth.encode_header(auth_config)
490
491 response = self._post_json(
492 u, None, headers=headers, stream=stream, params=params
493 )

Callers

nothing calls this directly

Calls 5

_urlMethod · 0.80
_post_jsonMethod · 0.80
_raise_for_statusMethod · 0.80
_stream_helperMethod · 0.80
_resultMethod · 0.80

Tested by

no test coverage detected