Adding these commands to a separate script seems like an unnecessary level of abstraction.
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.
The initial container is a contrived worst case example. Not necessarily a bad idea when you want to make a point but most of the gains are from not doing things you’re told not to do on page 2 of the docker tutorial.
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
3 comments
[ 3.4 ms ] story [ 18.1 ms ] threadConcatenating 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.
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