Think of images as classes and containers as instances of those classes.
Layers
Docker images are built from multiple read-only layers. Each Dockerfile instruction adds a layer on top of the previous ones.
When an image becomes a container, Docker picks the image and adds a writable top layer. It also sets IP address, name, ID, and resource limits.
During image build, a new layer is created when a Dockerfile instruction runs against the previous layer. After the instruction finishes, the temporary build container is removed unless you pass --rm=false.
View all layers with:
docker history <image>
Union file systems
Union file systems let you mount several file systems on top of each other so they appear as one. Directories can contain files from multiple backing file systems; if two files share the same path, the most recently mounted one wins.
Docker supports several UnionFS implementations:
Check which driver your host uses:
docker info
Look for Storage Driver in the output.
Unless you have a specific reason to pick something else, AUFS or Overlay are reasonable defaults — though they may require kernel support.
Related topics
- Creating images — Dockerfiles and build workflow
- Manual image creation
—
docker commit - Export and import — flatten or move images
- Storage drivers — driver trade-offs in detail
Andrew Dorokhov