Docker Tip #11 - Speed up Docker image creation

When creating docker images you will find out soon that image creation can take a while if your Dockerfile becames unwieldly. What can you do?

Create intermediate images

If you know that a particular part is going to be fairly stable factor it out into its own Dockerfile so you do not keep rebuilding that part over and over again. Use FROM to use the intermediate image you created.

Host artifacts locally

If you fetch artifacts from a location on the Internet you might want to download them manually and then host them yourself within your own network. This will speed up image building considerably as you are not going to the outside world to get your data.

Limit the number of lines in your Dockerfile

While you are certainly free to have any number of lines in your Dockerfile you might want to consider making it so the you limit the number of RUN statements, by combining them, as each RUN statement will spawn an additional process during image build.

Posted September 8, 2016