Layer sharing in memory

Posted on

I cannot find a definitive answer for this question. I get different answers from different sources.

I know images share layers because they are read-only and there is no reason to waste disk space.

What about containers at runtime? Do they also share the underlying layers?

If I have an image whose CODE takes up 55MB when running in a container, if I run 3 containers from the same image is the RAM used 3 * 55MB = 165MB or is it 55MB for the first with the others sharing the same memory pages?

I've attached a drawing to illustrate. Is it Drawing 1 or Drawing 2.

Container Layers