Event history is the ordered record of an image’s filesystem layers and build steps. Each Dockerfile instruction can add a layer, and later deletions hide files without removing their earlier layer. section 17.1
Use image history to inspect image structure and find avoidable size:
- Run docker history on the image to expose layer sizes and the COPY step that added unnecessary files. section 17.1
A deletion does not erase a layer
COPY . . followed by RUN rm -rf docs hides docs in the merged filesystem, but the copied files remain in the image stack. Prefer COPY ./app ./app so unwanted files never enter a layer.
