In this blog post I will provide practice how to get latest nginx version aligned with docker documentation.
You have web application, and you need proxy server. You decided to go with nginx using docker. Also, you need to modify original image, so you have your own Dockerfile that is based on official docker nginx image (first line in Dockerfile is FROM nginx:latest).
Everything is set up, and after some time, you realized that your
command does not gets latest nginx version despite the fact that you have in Dockerfile
This was my heuristic that failed. Then I tried solution that is not aligned with docker. In Dockerfile I put:
sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx
because nginx docker image is based on debian linux distribution.
Doing that, local docker image got bigger than it should be.
Investigating docker documentation for build, I found following for docker build option:
--pull false Always attempt to pull a newer version of the image
By default, option is set to false. So, in order that on every build you get latest nginx docker image, you should run following cmd:
docker build –pull
Your local docker image will have optimized size, based on original Dockerfile and your application would be more secure.