Sometimes we face some nginx vulnerabilities,
so we need to fix the nginx vulnerabilities inside ingress-nginx,
but the docker build -t image is too slow.
The reason is that the dockerfile internal will make compile and make install process.
How to add some parameters can make the docker build process faster?
Although the docker build process prompts make to add the -j
parameter to increase threads to speed up the process,
there is no make related parameter inside the dockerfile.
It is not a good idea to modify the dockerfile directly.
Source of the dockerfile.
2
Answers
docker version: docker-ce.20.10
Actual testing of images made by buildkit
may actually do little to improve the efficiency of making images if they involve a lot of compilation processes internally.
Maybe based on the official alpine base image,
consider add the -j nproc parameter in dockerfile to increase the threads, would be a good direction.
There is no one good solution on how to speed up the building of a Docker image. This may depend on a number of things. That is why I am posting the answer of the community wiki to present as many solution proposals as possible, referring to various tutorials.
There are a few tricks you can use to speed up building Docker images.
First I will present you solution from Google cloud:
You can read more here about Docker Layer Caching.
Another way is Structure your Dockerfile instructions like an inverted pyramid:
You can also Only copy files which are needed for the next step.
Look at these great tutorials about speeding building your Docker images:
–5 Tips to Speed up Your Docker Image Build
–Speed Up Your Development Flow With These Dockerfile Best Practices
-[Six Ways to Build Docker Images Faster (Even in Seconds)](# Six Ways to Build Docker Images Faster (Even in Seconds)
At the end I will present you one more method described here – How to speed up your Docker image build? You can you a tool Buildkit.
Hope it helps 😉