My container is running NGINX 1.24.0, I am trying to update the NGINX version to 1.25 but when I am trying to update the NGINX version inside the container using "apt-get install nginx" it is saying the latest version is already installed?
How to update the nginx version inside the container?
docker exec -it /bin/bash to get inside the container file system and run apt-get install nginx to update nginx
2
Answers
i assume that you are using the official nginx image, thus you should not update nginx within the image but rather use an official image with the version that you want.
First of all: Updating a docker-container with
docker exec ...
is never a good idea. These updates are not persistent and will be lost, when the docker container stops.But … howto update?
Best answer, it depends. You wrote no information which image you are using. So there are two variants.
Own docker-image
If you have your own dockerfile which looks like this
then you just have to do a
docker build . -t myImage:tag
.Official nginx docker-image
When you use the official nginx image, then the current version is marked by the tag.
docker run nginx:latest
will run always the newest version. It will change over time.docker run nginx:1.25.2
will run the current latest version (this image will be always the same).docker run nginxinc/nginx-unprivileged:1.25
will run always the latest rootless1.25
version. It will change, when small updates/hotfixes are provided.You can force an update by running
docker pull nginx/...
.Remember, you have then to stop & start all your nginx docker-container.