Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Docker tag command

Docker tag command

Docker Command ReferenceDocker Command Reference


docker tag The command is used to create an alias (tag) for a local image. By tagging an image, you can use easier-to-remember names or version numbers to identify and manage images.

Syntax

docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

** 1. Tag an image**



docker tag myimage:1.0 myrepo/myimage:latest

This marks the local myimage:1.0 image as myrepo/myimage:latest.

** 2. Add multiple tags to an image**



docker tag myimage:1.0 myrepo/myimage:stable

docker tag myimage:1.0 myrepo/myimage:v1.0

This marks myimage:1.0 as myrepo/myimage:stable and myrepo/myimage:v1.0 respectively.

** 3. Tag an image to push it to Docker Hub**



docker tag myimage:1.0 myusername/myimage:1.0

docker push myusername/myimage:1.0

This marks the myimage:1.0 image as myusername/myimage:1.0 and pushes it to Docker Hub.


Example

Tag an image

1. List local images



docker images



REPOSITORY          TAG       IMAGE ID       CREATED        SIZE

myimage             1.0       123456789abc   2 days ago     500MB

2. Tag an image



docker tag myimage:1.0 myrepo/myimage:latest

3. Verify the tag



docker images

Example output:



REPOSITORY          TAG       IMAGE ID       CREATED        SIZE

myimage             1.0       123456789abc   2 days ago     500MB

myrepo/myimage      latest    123456789abc   2 days ago     500MB

Notes

docker tag The command is an important tool for managing Docker images; by tagging images, you can easily identify, manage, and publish different versions of images. This command applies to a variety of scenarios, including version management, image publishing, and image replication. When using it, ensure tag names are standard and descriptive, to improve the efficiency and maintainability of image management.


Docker Command ReferenceDocker Command Reference