For people that followed my walk through on installing and setting up Docker, Docker Compose and Portainer on a new Ubuntu Server, I covered how to do the initial volume and container deployment of Portainer. The Portainer community pushes version updates to fix issues quite often and updating the container can be a little confusing. How do you update the management system that you use to manage the system itself…? Hopefully this will clear up any confusion.
How to know when to update?
When you login to the main Portainer Dashboard, if you look at the bottom left corner of the screen, you will see a “New version available” notification.
When you see this, its time to update!
Update Process
First thing we need to do is download the latest Portainer image.
Login to your current Portainer interface and navigate to “Images” on the left panel.
Locate the image that is currently being used. You will find this by looking at the “Tags” area and find “portainer/portainer-ce:latest”. Click on the “ID” to view details of the image.
At the top of the screen, in the “Image tags” area, click the “Pull from registry” button to download the latest version.
You will then be prompted on “Which registry do you want to use?”, the default “Docker Hub (anonymous)” is fine and click “Update”.
When it is finished downloading, you will see a pop up message in the top right corner of the screen.
You can now see your new image by clicking back to the “Images” screen and it will be listed at the latest tag but the ID will have a “Unused” flag next to it. You will also notice that the current version tag has switched to “none”.
Next we will need to redeploy the container while telling it to use the new version.
Redeploy Portainer Container
First we need to stop the old container. Login to a SSH session on the server you want to upgrade and execute the following command:
docker stop portainer
Then we need to remove the old container so it can be recreated with the new image. Don’t worry, all your settings will be saved into the volume which it will use to re-build the new container.
docker rm portainer
Lastly, we just need to execute the docker run command with all the information needed to rebuild the container.
docker run -d -p 8001:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Thats all there is to it. Now if you go back to the admin interface and login, you should see in the bottom left corner that you are on the new version.
Cleanup
There is a little bit of clean up that you will want to do after you are sure everything is working as expected.
You will need to go back into the “Images” menu and remove the old image to clean up space on your storage. You will find it by looking for the “Tags” which will be “portainer/portainer:none” and the “ID” will have the “Unused” flag next to it.