dockerdocker-image

Do docker images with different tags weigh the same separately?


I have been doing deployments for some projects for quite a few weeks, therefore I have several images for the same repository with different tags I have been doing deployments for some projects for quite a few weeks, therefore I have several images for the same repository with different tags. So with docker images I get things like this on my local:

enter image description here

I delete some image from a tag, but I don't free up 330 MB of storage. So doesn't each of these images weigh 330 MB separately?

I had understood that docker with its layer system would simply put layers on top of others if necessary, but this log has me a little confused.


Solution

  • The size listing is a simple sum of all of the layers for an image. There's no easy/good way to accurately list the unique layer size of the image in a way that would make everyone happy. Since there will frequently be a number of layers in common between images, trying to sum the size of multiple images will often double count those shared layers.

    The other images on the machine can change over time, which would mean a unique size would change as other images are added and deleted, require expensive recalcuations with every build/push/pull/delete. And not including the size of the shared layers in the listing would mean some layer usage would be unlisted until all common images are deleted. And users tend to want to know how much space an image is using even if there are common layers since that indicates an upper limit on space that will be needed if the image is pushed/pulled to another machine.