Docker Community Forums

Share and learn in the Docker community.

Relative impact of combining multiple RUN commands?


(Davidmichaelkarr) #1

I noticed in “Docker in Practice”, they suggest that you might get more compact images if you selectively combine multiple “RUN” commands into single commands. For instance, if you’re installing 20 packages through apt-get, instead of doing each on its own RUN line, just specify them all on a single “RUN”. This saves space because Docker creates a separate layer for each “RUN”.

I can see that this is possible, but how significant are these savings? Obviously, there is value in creating those layers, for various reasons, but this might be a pragmatic option if storing and sending numerous image files is having an impact on overall system performance.

However, if the space savings are negligible, then it’s moot. Does anyone have an idea of the relative space savings from this kind of change?