How do you reduce `apt` layer bloat and improve reproducibility?
IntermediateProductionBuild Performance & CI
Answer
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends ca-certificates=20230311 curl
(When using cache mounts, disable the Debian docker-clean hook.) Pin or snapshot repos (snapshot.debian.org) if you need byte-reproducible builds.
More on Build Performance & CI
How do you make Docker builds fast in CI where runners are ephemeral?BeginnerWhat are the cache backends in buildx?BeginnerWhy does `inline` cache often disappoint?AdvancedHow do you structure a Python Dockerfile for the best caching and size?IntermediateHow do you structure a Node.js production image?IntermediateHow do you build a small Java image?Beginner