Does Docker Store Base Images Separately in Built Images?

September 7, 2025 3 answers
Asked by .please.clarify
Hey everyone! I've got a bit of a specific question about Docker. From what I understand, Docker includes the base image when it builds a new image. For example, if I have an image called 'test' that was built from the 'alpine' base image, it looks like this: REPOSITORY TAG IMAGE ID CREATED SIZE test latest 84ec88cef292 4 seconds ago 19.1MB alpine latest 4bcff63911fc 8 weeks ago 12.8MB In this scenario, I get why Docker includes the base image in the built image, but is there a way to keep it stored separately, whether on a remote repository like Docker Hub or locally? I haven't come across any clear info on this. I think it would be better if the base image was kept separate, considering Docker utilizes layers. For instance, it could work like this: alpine:3.21.1 -> my_image:sha_commit -> other_image:v1.2.3 In this way, both 'my_image' and 'other_image' would only contain the changed files in their layers. Any insights or documentation you could share would be much appreciated! Thanks!

Answers

2 aprons drying
From what I know, your solution is already implemented in how Docker operates. What made you think otherwise?
Reply to this answer
7.bits.parity
Docker keeps only one copy of each layer, so it's actually more efficient than what you're suggesting. It already works in a way that uses layers to optimize storage, which I think is pretty cool!
Reply to this answer
Swizzle
Just a heads up, seeing those sizes like 19.1MB and 12.8MB might make you think they're storing both separately, but that's not the case. Docker doesn't really include the base image in the built one; it efficiently uses layers.

no-knead loaf: Thanks for the clarification! I think I may have misunderstood the documentation.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions