To create a Docker image tag, you can use the docker tag command. Here’s how to do it:
-
Pull or have an existing image: First, ensure you have the image you want to tag. For example, let's say you want to tag the
nginx:latestimage. -
Use the
docker tagcommand: The syntax for tagging an image is as follows:docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]Here’s an example command to create a new tag for the
nginx:latestimage:docker tag nginx:latest my-nginx:v1In this command:
nginx:latestis the source image and tag.my-nginxis the new image name you are creating.v1is the new tag you are assigning.
-
Verify the tagged image: You can list your images to see the new tag using:
docker images
You should see both nginx:latest and my-nginx:v1 in the list, indicating that the tagging was successful.
