I am brand new to Docker and following the Getting Started tutorial. At step 7 it says
type
docker images
command and press RETURN. The comma
I will try to explain this in a very sharp and clear manner.
Docker Image Name
Docker Image actually doesn’t have a name per se. It has an ID, Repository and a Tag (which, according to Docker docs, stands by the way for Target Image, not the English word tag). So, each time we refer to Docker Image name (either creating, running, removing, pulling it or etc.) we actually refer to the Image Repository:Tag (target image).
We just quite often happen to omit the tag part (by just writing the repository name, which we consider as an Image name), and that’s when docker assumes default tag which is :latest
(i.e. Target image latest)
Docker Repository
Docker, when building/creating an Image, creates repository for that image and Image itself, it then adds that current (:latest
tag) image into that repository. According to Kubernetes in Action by Marko Luksa, Image tags enable us to have several versions (tags) of the same image under the same image name. So we may have myapp:latest, myapp:v1, myapp:v2 all under one identifier and each tag here will refer to a particular target image, i.e. particular snapshop/version of the same app.
That's why docker names the Image Repository and leaves the differentiation job to tag, as one repository should (and must) probably contain different versions of the same application.
So, if we run docker build -t A .
, docker will actually create an Image Repository A and the Image itself (with :latest tag). It will then add that image into repository A. Later on, we’ll be able to push/pull particular snapshots of that image.
P. S.
The way we're used to call Docker Image name, is (and can be assumed as) actually Docker Image Repository[:tagname] and the latter is optional, by default :latest
You can test all this and prove to yourself by trying to remove the image without specifying tag to it and when that image repository doesn't have a default :latest image in it. Just run docker rmi myimage
and you'll see, that docker will complain, saying Error: No such image: myiamge
as by default (when you don't provide tag) it assumes and implies :latest tag.
Hope this sheds more light on this topic.