Installing system packages in Docker with minimal bloat
pythonspeed.com
pythonspeed.com
Also, while vanilla Dockerfiles do need to carefully clean up after themselves BuildKit offers you a friendlier way of handling this with ‘--mount=type=cache’ on the appropriate directories
Concatenating the commands with &&, adding "--no-install-recommends", and adding " && apt-get clean && rm -rf /var/lib/apt/lists/*" to the Dockerfile seems much more straightforward and maintainable.