Why removing image shows multiple images instead of one

So I am trying to build a container from an image. However I have been interrupting the process several times whenever there is an error. I have noticed that docker might have created a new image. So whenever I want to start from scratch I try to remove the newly created image and this is where I see a strange behavior. I run a docker rmi expecting only one image to be removed but that is not the case because the output shows several of them have been removed. Below is an example of what is happening on ubuntu machine.

root@trustytahr:~# docker rmi 00ac1e3
Deleted: 00ac1e3eba63d0ca376e4baa949b55e987429e689d3ea1774d920c24d8d37eb0
Deleted: b023f2db4b0e0b0741935e713a7bdb211d2bcaa9fbd4f6e84a14bba79c5c92d4
Deleted: 77cc7fcb42be6427cf94d3f154760404d88497321660629213862d261f46ae82

The question is why does this happen? Or rather what does this mean?

Docker images are made of one layer per Dockerfile instruction, so if you delete an image which has several layers that are not also used for some other image, those sub-layers are also deleted.

1 Like