In this tutorial, we’ll take a look at how to update Portainer. Portainer is an application that you can use to manage your Docker containers. It can be installed on various different devices that run Docker, but periodically, there are updates that must be installed.
When an update is released, it’s sometimes confusing to install as Portainer generally manages your Docker containers. Portainer makes updating Docker containers incredibly easy, but you must ensure that you keep your Portainer instance up to date as well for new features and that’s what we’ll be looking at in this article.
If an update is available, you’ll see a message in the bottom left of Portainer informing you that an update is required.
The update process is slightly different than it is to update other containers since you can’t stop Portainer and still access it from Portainer. However, you can easily update it if you can get to the command line where you have Docker and Portainer installed.
You can accomplish this by either SSHing into the device hosting Portainer or accessing the terminal through a GUI/the device itself.
How to Update Portainer to the Newest Version
Now that we understand exactly what Portainer does, we’re going to look at how to update Portainer.
1. Connect to the host where Docker is installed. In the example below, I used SSH to access Docker, but you can access it however you’d like.
ssh username@DOCKER_IP
2. Run the command below to get the Docker containers that you have installed and get the container ID for Portainer.
sudo docker container ls
3. Run the command below to stop the Portainer container.
sudo docker stop portainer
NOTE: If the command above does not work, stop the container using the container ID
sudo docker stop [CONTAINER_ID]
4. Delete the Portainer container by running the command below.
NOTE: If your prior instance of Portainer did not have a persistent volume, your data/configuration will be lost.
Ensure that you have the important data that exists in the /data location of the Portainer container or you will have to recreate your user account and modify your settings.
sudo docker rm portainer
NOTE: If the command above does not work, delete the container using the container ID.
sudo docker rm [CONTAINER_ID]
5. Pull the latest version of the Portainer container.
sudo docker pull portainer/portainer-ce:latest
6. Recreate the Portainer container using the command 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
7. You can log back into Portainer and it will be updated!
Conclusion & Final Thoughts on Updating Portainer
This tutorial looked at how to update Portainer. Portainer is the way I’ve been managing my Docker containers for a long time and it’s worked flawlessly. There are other options available, but this is an easy way you can update and manage your containers.
As explained in the article above, please make sure that you have the Portainer data in a persistent volume before updating the system. While it’s not a massive issue if you have to start from scratch (since Portainer is really only used to manage Docker containers), it is always best to have persistent volumes for your Docker containers if possible.
This ensures that after any container is updated (Portainer included) the data will still exist and you’ll continue operating the way you always have. This is also beneficial if you’d ever like to migrate the container to a separate device.
Thanks so much for checking out the tutorial on how to update Portainer. If you have any questions, please leave them in the comments!