April 2017
Beginner
404 pages
9h 30m
English
On the contrary, we can optimize the build speeds if we split the instructions into multiple RUN commands. This is because each RUN instruction that is converted into a layer is cached by the Docker build system, while building an image. If Docker finds an instruction which is repeated, Docker uses the cached layer instead of creating a new layer. The result is that Docker's build speed is increased.
For example, the following Dockerfile downloads and installs the Visual Studio redistributable package and Apache, and then cleans up the files. Since this is all done in a single RUN instruction it creates only two layers:
FROM windowsservercore RUN powershell -Command \ # Download software ; \ wget https://www.apachelounge.com/download/VC11/binaries/ ...Read now
Unlock full access