Pcornel
Containers · Container Fundamentals

Container Images and Layers

Cheat sheet · https://pcornel.dk/topic.php?topic=6121

Back to the Topic

Answer

A container image is an ordered stack of read-only layers (each a filesystem diff) plus a config (entrypoint, env, user). Containers add a thin writable layer on top using a union/overlay filesystem.

Remember

Each Dockerfile instruction can create a layer; files deleted in a later layer still exist in earlier ones (and in the image size). Order instructions so rarely changing layers come first for caching.

First checks

  • docker history <img> — layers and sizes
  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Verify in this order

base layer → added layers → image config → container writable layer

Where it usually breaks

Copying secrets in one layer and deleting them in the next still ships them.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6121

Confirmation

Confirm action

Continue?