I'm trying to understand the following commands
docker image prune
docker image prune -a
According to the docs
docker image prune: Removes dangling images
docker image prune -a: Removes dangling and unused images`
I'm trying to understand the difference between a dangling and unused image.
According to this stackoverflow post, an unused image is an image that has not been assigned or used in a container.
So basically, if I run
docker pull hello-world
(having never executed the command docker run hello-world
)
Then the image for hello-world would be an unused image??
How are dangling images created then?
According to the above referenced stack overflow post, "a dangling image just means that you've created the new build of the image, but it wasn't given a new name. So the old images you have becomes the 'dangling image'."
What exactly does that mean? I.e, what does it mean to create a new build of the image? How do you create a new build of the image? What are untagged images?
Can someone give me an example of how a dangling image is created?
Dangling image simply means you have an image, but it has no tags attached to it. (Prune unused Docker objects)
How do you reach it? by building an image with the same name and the same tag. That's the usual case, not the only one.
my.image.example.com
and tag it with latest
.my.image.example.com:lastest
This is very high level and abstracted description of what an image tag is;
Most if not all computer softwares are composed by a name and a version. For example, your OS might be Windows 10, OSX Catalina (14 Mojave), etc.
In the containers world, the image tag is used to address the version of the software. The image name - is the software itself.
When you download an image, you specify the image name and its "version" (which is, the tag). That's the common use-case. Tags can be used for many purposes; there can be many tags to a single image, but not a single tag that references multiple images.
I think Docker overview can be a good place to get some fundamental background of the platform