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

Method tag

docker/api/image.py:542–572  ·  view source on GitHub ↗

Tag an image into a repository. Similar to the ``docker tag`` command. Args: image (str): The image to tag repository (str): The repository to set for the tag tag (str): The tag name force (bool): Force Returns: (

(self, image, repository, tag=None, force=False)

Source from the content-addressed store, hash-verified

540
541 @utils.check_resource('image')
542 def tag(self, image, repository, tag=None, force=False):
543 """
544 Tag an image into a repository. Similar to the ``docker tag`` command.
545
546 Args:
547 image (str): The image to tag
548 repository (str): The repository to set for the tag
549 tag (str): The tag name
550 force (bool): Force
551
552 Returns:
553 (bool): ``True`` if successful
554
555 Raises:
556 :py:class:`docker.errors.APIError`
557 If the server returns an error.
558
559 Example:
560
561 >>> client.api.tag('ubuntu', 'localhost:5000/ubuntu', 'latest',
562 force=True)
563 """
564 params = {
565 'tag': tag,
566 'repo': repository,
567 'force': 1 if force else 0
568 }
569 url = self._url("/images/{0}/tag", image)
570 res = self._post(url, params=params)
571 self._raise_for_status(res)
572 return res.status_code == 201
573
574
575def is_file(src):

Callers

nothing calls this directly

Calls 3

_urlMethod · 0.80
_postMethod · 0.80
_raise_for_statusMethod · 0.80

Tested by

no test coverage detected