arrow_back
Back

Docker images: layers, UnionFS, and storage drivers

Andrew Dorokhov Andrew Dorokhov schedule 2 min read
menu_book Table of Contents

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.

code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Docker image commands: build, tag, pull, push, and export

arrow_forward