docker:tldr:9277f
The docker tag
command is used to add a new name and/or tag to an existing image in Docker. It allows you to create an alias or make a copy of an image with a different name or tag.
The syntax for the docker tag
command is as follows:
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Here, SOURCE_IMAGE
refers to the image you want to tag, and TARGET_IMAGE
refers to the new name and/or tag you want to assign to the image.
For example, suppose you have an image called myimage
that currently has the latest
tag. You can tag it with a new name and a different tag using the docker tag
command like this:
docker tag myimage:latest newimage:1.0
This will create a new image called newimage
with the tag 1.0
, which is essentially a copy of the original image.
You can also use the docker tag
command to create multiple tags for the same image. For instance:
docker tag myimage:latest myimage:2.0
This will add a new tag (2.0
) to the existing image (myimage
), so you can refer to it using either tag.
Tags serve as human-readable labels to identify or version your images. They can help manage different versions of the same image or facilitate deployment to different environments.