Since the image webdevops/php-nginx
doesn’t have the option to specify your desired Nginx version, we can adjust the Dockerfile and add that option. Let’s see the solution.
Prerequisites
- webdevops/php-nginx image
- sudo privileges
Solution
- First, you need to determine the version of nginx you want to update to. You can check the available versions on the official nginx website or by running the following command:
docker run --rm webdevops/php-nginx:alpine nginx -v
- Once you have determined the new version of nginx, you need to modify the Dockerfile for the
webdevops/php-nginx:alpine
image.FROM webdevops/php-nginx:alpine RUN apk update && apk add nginx=<new_version>
Replace
<new_version>
with the version of nginx you want to update to. - Build the new Docker image using the following command:
docker build -t <new_image_name> .
- Test the new Docker image to make sure that nginx is updated by running the following command:
docker run --rm <new_image_name> nginx -v
Conclusion
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.