is there any advantage to aim for fewer layers in an image rather then many?
in other words … would:
RUN apt-get install vim
RUN apt-get install curl
… be less ideal then …
RUN apt-get install vim curl
… when building an image from a
ok, that’s what Overview of best practices for writing Dockerfiles | Docker Docs
has to say in this regards
Minimize the number of layers
You need to find the balance between readability (and thus long-term maintainability) of the Dockerfile and minimizing the number of layers it uses.
Be strategic and cautious about the number of layers you use.
So my example would ideally look like this (according to them)
RUN apt-get update && apt-get install -y \
Also remember that, if you want to delete anything, you must delete it in the same layer you create it or it doesn’t save any space. My Dockerfiles frequently look like
RUN apt-get update
&& env DEBIAN_FRONTEND=noninteractive \
apt-get install --assume-yes --no-recommends \
&& apt-get clean