How to restart Portainer?

This is probably directed at @kanga_who as it their guide I followed to set up my NUC.

It is a long story, and I’m not yet at the end of it, but I had to reboot the NUC. Everything seems to have come back except Portainer.

Do I have to start it separately?
Is there a way to make it start automatically?

Thanks.

It should start automatically if you copy/pasted the line from the guide

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

You can also use this from command line/putty to start.

sudo docker start portainer
2 Likes

I restarted and all is good…

After my previous restart I did an apt-get update and apt-get upgrade (I can never remember which comes first without checking!). Obviously it needed a restart to complete. Which makes sense of course.

Thank you, clearly I still have some way to go with learning Linux.

One last thing, how do I upgrade Portainer?
I’m getting a message saying, “upgrade your Portainer instance to 1.22.2. This release offers fixes to a range of security issues that have come to light in our ongoing testing

Thanks again…

So I use docker-compose and also watchtower for my non-HA containers. Watchtower will automatically detect and update to a new version.
With docker-compose you do a pull, down and up to get new images and run again. Much better than running commands.

Actually with docker compose
docker-compose pull && docker-compose up -d

When compose senses a change it will restart just the docker that has changed.

docker pull portainer/portainer
docker stop portainer
docker rm portainer
docker run ... <your run parameters etc>

@flamingm0e, Thanks.

As I said…

Can I just try and understand this,

docker pull portainer/portainer - This gets the latest version
docker stop portainer - This stops the Portainer container

docker rm portainer - This removes Portainer but I’m confused as to why this would be done after getting the latest version?

docker run ... <your run parameters etc> Fairly self explanatory, except…

What are the run parameters?

You have to stop and remove the container to USE the newest version.

See everything after the word run? Those are parameters for the docker to use.

1 Like

Ok so previously I was using your command:

docker-compose pull && docker-compose down && docker-compose up -d

Are you saying I should remove the down part of that?

I didn’t know that. Thanks. Good info.

You could also set up docker-compose and in a docker-compose.yml file:

version: '3.7'
services:
  portainer:
    container_name: portainer
    restart: unless-stopped
    image: portainer/portainer
    volumes:
      - /home/docker/portainer/data:/data
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "9000:9000"

Then you can add other stuff easily as well and just use one command to manage all non HA containers.

All the prebuilt containers on linuxserver.io have similar code there for you to cut/paste and modify for running docker containers. It’s pretty cool.

Yeah, it took me a while to find out that the up -d would handle the regen of the container.

Yep.

1 Like

That will be faster as well and will only restart the docker that is changed as well…

I still need to pull my containers down though because it doesn’t map the data folder on my NAS before docker has started so I do have to restart the containers anyway. I have never been able to find a way to make docker wait to start until the drive is mapped…

Have you tried this yet?

https://soichi.us/systemd

In all my searches I never found that!
Just tried it but it doesn’t work.
Thanks though…

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service var-synology.mount
Wants=network-online.target var-synology.mount
Requires=docker.socket

I haven’t tried it yet, but I have a similar issue on another docker host, so I will try to figure something out.

I’m reluctant to add the mount to requires as well… It’s odd it doesn’t work for me. Be interested if you get it to work. Seems like the ideal solution.

Even if I could delay docker starting for a minute…

Here’s another post with the same ‘solution’ on the docker forum but he can’t make it work either.

Thanks, I have some research to do!

Is it also possible to restart a container that I created in Portainer?

Portainer or not, docker is the same. docker restart <containername>

Or you can use the interface in Portainer and restart it from there.

oh, thnx
but i dont want todo it from the interfacce, i want to restart my container scheduled with an automation

thnx for that info!