A while ago I wrote a post about Portainer. In the meantime a new version has been released and I received a question in the comments from Cheng about how to update Portainer to the latest version.
This is a very good question and I remember going through the same question in the beginning. So the update process of Portainer looks like below;
- Get the latest image tag from the Docker Hub repository. NOTE: I’ve filtered this on arm64 but if you’re using the 32bit OS, simply delete the 64. Now copy the latest tag and paste it to notepad.
- Login to your RPi using SSH
- List your containers by typing the below command.
docker ps -a
- Copy the “Container ID” + “Image Name” of Portainer. You’ll be needing this later.
- Stop the Portainer docker using the below command
docker stop <CONTAINER_ID>
- Remove the Portainer docker using the below command
docker rm <CONTAINER_ID>
- While we’re at it, let’s remove the old image as well.
docker rmi portainer/portainer-ce:linux-arm64-2.11.0
- Now, verify that Portainer is removed by re-typing or hitting the UP arrow three times;
docker ps -a
- Now, rerun the same command as you used when you installed Portainer for the first time and you’re done.
NOTE 1: Change the path to your own path if needed. In the example below /home/pi/Configs/Portainer is the path that I’m using!
NOTE 2: Don’t forget to use the newest tag which, at the time of writing this article, is 2.11.1.
docker run -d -p 9000:9000 --name Portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /home/pi/Configs/Portainer/:/data portainer/portainer-ce:linux-arm64-2.11.1
Now your RPi will start looking for the latest image locally but since we didn’t downloaded upfront, it will automatically look for it in the Docker hub.
As soon as the image has been pulled, it will be installed and you can log back in! And that’s it! You can now go to Portainer and you can log into Portainer.