November 4, 2026 路 #49
The package list from last month
The build started failing with 404s from the Debian mirror, and old builds missed security fixes. Which line causes it?
FROM debian:bookworm-slim
RUN apt-get update
RUN apt-get install -y --no-install-recommends curl ca-certificates
COPY app /usr/local/bin/app
USER 10001
ENTRYPOINT ["/usr/local/bin/app"]Next puzzle in UTC
One try. The first answer sticks.
How to fix it
Docker caches line 2 as long as the line text is unchanged. Line 3 then installs against an index that can be weeks old. Update and install in one RUN.
Docker decides whether to reuse a layer by the instruction text and its parent, not by whether the mirror changed. RUN apt-get update never changes, so it is cached forever on a build machine. When you later edit the install line, it runs against the cached index. Packages that were replaced on the mirror return 404, and versions with security fixes are invisible.
Fix
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
One layer means update and install are always cached or rebuilt together. Removing the lists keeps the image small. Rebuild on a schedule with --pull --no-cache so security fixes reach the image even when the Dockerfile does not change.