Container Images and Layers
Cheat sheet · https://pcornel.dk/topic.php?topic=6121
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 sizesdocker ps -a— containers and exit codesdocker logs <c>— container outputdocker 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