Categories: Docker

How to update Portainer container (easy way)

 

Updating your Portainer server it’s pretty easy if you follow this tutorial.

I suppose you didn’t use docker-compose if you don’t know what it is don’t worry, I’ve written both solution in this tutorial.

Before you start go on Portainer web interface Containers>Portainers and check the Volume section.

Be sure that you have the portainer_data to /data, otherwise, you are going to lose all your container configurations.

How to stop and delete the Portainer container

Open your terminal and write

sudo docker ps

Now you’ll see all the containers that are running.

We need to stop the portainer/portainer container. Your CONTAINER ID is gonna be different from mine, so change it.

You don’t have to write all the id, the first three numbers are enough.
sudo docker stop 498

It should print the same number.

Now we need to remove the container using the rm command.

sudo docker rm 498

Also here it should print the same number.

How to remove and update the Portainer image

Now we need to remove the old image of Portainer. I have seen some tutorials where they don’t do it but they were not working for me.

sudo docker image ls

Now you need to do the same thing but with the IMAGE ID.

sudo docker image rm 2869 --force

Now we can finally run again the Portainer container. Since we deleted the old image it’s going to download the latest one from docker.

We just need to run the same command that we run during the first installation

docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Now your Portainer web interface should be again accessible and updated.

If you successfully updated your Portainer container please leave a message here or vote the tutorial, so I can now if it’s still working or not.

Update Portainer using docker compose

If you are using a docker-compose.yml file like this one you it should be easier to manage everything.

version: '2'

services:
  portainer:
    image: portainer/portainer-ce:latest
    command: -H unix:///var/run/docker.sock
    restart: always
    ports:
      - 9000:9000
      - 8000:8000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:

If these commands don’t help you can follow the previous instructions about how to delete the old image and download the new one.

sudo docker-compose down
sudo docker-compose up -d

If you can’t update Portainer leave a message and I’ll try to help you.

 

Alessandro Oppo

Alessandro è un milanese che vorrebbe scappare da Milano, è appassionato di informatica ma vorrebbe vivere senza telefono, è un artigiano eppure vorrebbe robotizzare tutto, impara una cosa e già vorrebbe studiare dell’altro. Autodidatta da sempre, gli piace sbattere la testa finché tutto non funziona come vuole lui, spesso ci riesce anche! Visita il suo blog personale alexoppo.com Il motto che si ripete dentro la testa è: “Se ci sono riusciti gli altri ci posso riuscire anche io”.

View Comments

  • Specifically, in the last docker run command, change the "portainer/portainer" that specifies the image that will be used to "portainer/portainer-ce:latest".

    One should also make sure what is used for the second volume mapping argument, i.e. "portainer_data:/data" in this case, matches what the current portainer volume mapping setup is. You find that information in the portainer container details in your current running Portainer interface. Referring back to what one did "in the first installation" is likely impossible.

  • Thanks , as this worked so well,first time of trying!
    Could I be as bold to ask if you could advise on the best way to update nextcloud which is running on raspberry pi in docker

    • Hello, glad that it worked and thank you for the feedback.

      About NextCloud it should be possible to update it from the web interface, otherwise you could use Watchover.

  • Thanks for reply,I did try to update nextcloud using updater in web interface nothing happened!

    I will try using watchover, should I run docker command or docker compose?
    Apologise for my ignorance,I am learning bit by bit!
    Thanks again

    • Don't worry, docker at the beginning is a bit hard.

      For watchover just use the docker run command that it's provided on their github. It's just a container that pulls new images.

    • Sorry for my late reply. You can installa watchover with the docket run command they have on their docker hub page. Don't worry, docker at the beginning it's a bit hard.

  • Thank you for making this easy Alessandro! Great tutorial. I’m learning Docker as well. It seems like it has an interesting learning curve 🙂

    • I'm glad that it worked and thank you for the feedback! Yeah, docker is a bit hard at the beginning, but you'll learn a lot.

  • Since my parameters for portainer are slightly different than usual, a script called start-portainer.sh always has the docker run command. That way I never forget how to restart it after the upgrade. For which I use this post :-)

Share
Published by
Alessandro Oppo

Recent Posts

Ponti sospesi: cosa abbiamo sbagliato? cosa si potrebbe fare?

Poco prima di Natale ho avuto la fortuna di poter partecipare a un evento chiamato…

4 mesi ago

Siamo quel che facciamo? – racconto breve

Armando quel giorno era particolarmente stanco. Tutto, per quanto andasse bene, sembrava metterlo sotto pressione.…

9 mesi ago

Il limite è sempre la mente – Racconto breve

Armando guardò l’orologio e vide il proprio riflesso sul quadrante bianco. Il riflesso però non…

10 mesi ago

L’ultimo giorno del carcere – Racconto breve

I muri sono muri, lo sono sempre, anche quando le porte sono aperte. Era la…

10 mesi ago

Riflessioni sul carcere

Pochi di noi riflettono sull’esistenza nella nostra società del carcere. Il carcere è la concretizzazione…

11 mesi ago

Come dovremmo dialogare secondo me

Spesso intraprendiamo delle conversazioni e delle chiacchierate piuttosto inconsapevolmente. Voglio dire che non siamo molto…

11 mesi ago