How to Update a Docker Container using Portainer

  • Post author:WunderTech
  • Post last modified:November 14, 2023
  • Post category:Docker
  • Reading time:6 mins read

Today we are going to look at how to update a Docker container using Portainer.

There are many different ways to update Docker containers, but Portainer makes the process somewhat straightforward.

To demo how to update a Docker container using Portainer, I will be updating an Nginx Proxy Manager container. Currently, I’m running an old version (2.3.1) and we will be updating that to the latest version.

Before starting this process, ensure that your container is created properly and volumes exist with your important data. If the data is not mapped to a local folder, it will be overwritten with the latest image data.

How to Update a Docker Container using Portainer

Before you can update Docker Containers with Portainer, you must install Portainer.

Installing Portainer

1. Download and run the Portainer Container by running the commands below.

sudo docker run -d -p 8000:8000 -p 9000:9000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
how to install docker and portainer on debian - downloading the portainer container

2. This will install Portainer and it will be accessible by the workstation’s IP address and port 9000. When you get there, create a username and password.

http://[WORKSTATION_IP_ADDRESS]:9000
portainer debian - creating an account for portainer

3. Select Docker and Connect.

portainer debian - connecting to the local docker instance
4. Select Local.

local docker instance

Updating Docker Containers Using Portainer

Now that Portainer is installed, you can run the steps below to update Docker Containers.

1. Select Containers, then stop the container that you’d like to update.

portainer update docker container - nginx proxy manager container

2. Select the container, and you’ll see a button named Recreate. By selecting this button, the container will take the persistent data and recreate the container. Keep in mind that the only data that will stay on the container is data that was mapped to a volume. This is explained in greater detail in the video above.

portainer update docker container - portainer recreate button

3. Select Pull latest image, then Recreate.

portainer update docker container - downloading latest container

4. When this process is finished, the container will be recreated with the latest image. Select the container and Start it. The status will change to running.

portainer update docker container - update a docker container using portainer

5. The container will now exist with the newest released version!

new nginx proxy manager version showing it was updated

Conclusion & Final Thoughts

This tutorial looked at how to update a Docker Container using Portainer. As I stated above, this is not the only way of doing this. There are various ways, but this is what I consider to be the easiest. It’s good to periodically check and ensure that your containers are running the latest version.

Keep in mind that you can always recreate an existing container using an older version if you run into any unexpected problems. This is what makes Docker containers so easy to work with!

Thanks for checking out the tutorial on how to update a Docker Container using Portainer. If you have any questions, feel free to leave them in the comments!

WunderTech

Frank is an IT professional with 13+ years experience and the creator of WunderTech. He focuses on sharing his experience with others on computer hardware, servers, software, networking, and self-hosted apps. He has a BS in Computer Information Systems and an MBA. Learn more about Frank in his bio.

This Post Has 15 Comments

  1. Fabian

    Hello,
    I am just recently getting started with Docker and Portainer on my synology NAS and I find all your tutorials incredibly helpful and very well documented.
    One crucial part that I am sadly lacking is, how do I (correctly) install an image via portainer in the first place, especially where do I do the mapping between the synology folders and the mounted ones in the container?
    It is probably a total beginner question for you, but maybe it is worth it to do a tutorial on it. Maybe I am not the only one with this problem

    1. WunderTech

      That’s one of the main reasons I haven’t created a tutorial on Portainer. I love Portainer (use it for all other Docker instances on other OS’s), but I find it a little confusing on Synology’s. In summary, I believe that you have to set the exact volume path of the Docker folder. I am not positive of this (I will try and do some testing at some point), but that’s how I remember it working. I apologize as I know this isn’t the best help! Please let me know if I can answer anything else!

  2. Omar

    I’m following your youtube channel. Thank you for the great work. I wonder if you can provide us with an app template that works with Portainer on a Raspberry pi (arm based). Also, I wonder if you could show us how we can pull a Docker image from Docker Hub using Portainer, and create a stack on portainer. WordPress and SQL would be great. Kudus!!

    1. WunderTech

      Thanks so much! I will add these to my list of tutorials. I will also look into developing an app template one day!

  3. Steve

    Since portainer is an a container as well, can you describe how to update the portainer container itself?

    1. WunderTech

      The best way to update it is to delete the container (while keeping all of the volume information), and then recreating it with the same volumes. This will ensure that everything is updated and your data stays the same.

    2. Andrew M

      the best way to update the portainer container is to use the following from the command line (assuming you’ve installed it at default paths) :

      docker stop portainer
      docker rm portainer
      docker pull portainer/portainer-ce
      docker run -d -p 8000:8000 -p 9000:9000 –name=portainer –restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

  4. Evripidis

    Hey Frank, thank you very much for your valuable tutorials.

    What happens if an image has been renamed (like bitwarden-rs –> vaultwarden)? Will portainer be able to pull the latest image on its own, or do we need to somehow specify the new name of the image?

    1. WunderTech

      Thank you! Unfortunately, you will have to recreate the container. I feel like it’s fairly infrequent, but I suspect that there was a request from Bitwarden to rename the container for clarity purposes (since it’s not created by the bitwarden developers). I don’t think it happens that frequently, but in this case, I would recreate the container using the existing volumes and everything should function the exact way it always has.

      1. Evripidis

        Great! Thank you for the quick reply.

        Since I’m fairly newbie to the Docker world and just to be clear: when you say recreate the container, you mean stop/kill/remove the existing container and then create a new Bitwarden container from scratch (following for example your guide https://www.wundertech.net/how-to-self-host-bitwarden-on-a-raspberry-pi/) and map the existing volume, right?

        1. WunderTech

          That is correct! You can leave the old container there as a backup until you verify the new container is working.

          1. Evripidis

            Many thanks Frank!

            All went well, my new Bitwarden (powered by Vaultwarden) is up and running. I appreciate your help and your tutorials. Keep up the good work!

          2. WunderTech

            Glad to hear you got it working!

  5. Steve

    Stopping containers and …..RECREATE option is MISSING !
    Using latest 2.6.2 portainer.
    Has the option been removed or does it maybe only appear on some containers ?
    Not there for transmission, yacht, ghost.
    Really confused with how to update containers via portainer.

    1. WunderTech

      As far as I know, the option should be there. Are the containers reporting as “stopped” when you try and recreate them and is only one selected?

Comments are closed.