Source: medium.com

Optimizing a dockerfile

Category: Docker, nginx

There are 3 major points to consider when optimizing a Docker file: The build context is the entirety of the disk contents for the folder containing your Dockerfile, except parts ignored by .dockerignore. This can be massive - on a Javascript application, this means copying over node_modules, which would be installed as part of the build anyway! On a real world example, failing to add node_modules to my .dockerignore file yields: Sending build context to Docker daemon 788.6MB

Just ignoring node_modules reduces that to: Sending build context to Docker daemon 13.75MB

This leads to some extra layers in complex directory structures, but the advantages of this are huge.

Related Articles