Portainer: easy updating your Docker instance
Portainer is a really nice tool to manage your Docker containers, volumes and networks.
One of the things that may scare you at the beginning is how to update Portainer. It is really simple and you should not lose any data.
I use linux Ubuntu/Debian so in your case things may be different but should be easy to adapt the script You can create a simple script like this
#!/bin/bash
sudo docker pull portainer/portainer-ce
sudo docker stop portainer
sudo docker rm portainer
sudo docker run --name portainer --restart=unless-stopped -d -p 8000:8000 -p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data portainer/portainer-ce
It will:
- update your local Portainer image
- stop the container
- remove it (not the volume with data)
- start the new container
You can place it in your ~/.local/bin
with the name update-portainer and then add permission to execute it (like chmod +x ~/.local/bin/update-portainer
)
Now you can simply run update-portainer in your bash and your local Portainer container will be updated.
Easy. Have a nice day!