Union Filesystems — The Layering Magic

LEVEL 0

The Problem

We’ve learned that containers share the host’s kernel. They don’t each need their own full operating system.

But they do need their own filesystem. Each container needs to see its own /etc, /usr, /var, and all the files that make up the operating system userspace and the application.

If you run 10 nginx containers, each one needs the nginx binaries, configuration files, and libraries. Without some cleverness, you’d need 10 complete copies of all those files.

That would be wasteful. If all 10 containers use the same base image (like nginx:latest), they’re all using identical copies of most files. Why store the same data 10 times?

Even worse, imagine you have 50 containers all based on Ubuntu. Each one would need a full copy of Ubuntu’s filesystem—that’s gigabytes multiplied by 50.

This is the problem that union filesystems solve.