
This assumes you have installed Docker on Linux and Docker is running.
A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).
The docker images command can be used to return the list of images.
docker images
Let's say the bar image is untagged.
REPOSITORY TAG IMAGE ID CREATED SIZE
foo latest 105b54dc64f1 32 hours ago 196.7 MB
bar <none> 7bd4bc0f144f 32 hours ago 208.9 MB
The docker tag command can be used to tag an image. In this example, the bar image will be tagged with 1.0.
docker tag bar bar:1.0
The docker images command should now show that bar is tagged with 1.0.
REPOSITORY TAG IMAGE ID CREATED SIZE
foo latest 105b54dc64f1 32 hours ago 196.7 MB
bar 1.0 7bd4bc0f144f 32 hours ago 208.9 MB
The docker tag command can also be used to create another image with a different tag name. In this example, another foo image will be created with tag "prior".
sudo docker tag foo:latest foo:prior
The docker images command should now show two foo images, latest and prior.
REPOSITORY TAG IMAGE ID CREATED SIZE
foo latest 105b54dc64f1 32 hours ago 196.7 MB
foo prior 105b54dc64f1 32 hours ago 196.7 MB
bar 1.0 7bd4bc0f144f 32 hours ago 208.9 MB
Did you find this article helpful?
If so, consider buying me a coffee over at