Nethserver Docker and option --restart unless-stopped

Salut @stephdl

I have a problem with Nethserver Docker and the option --restart unless-stopped

When I installed Portainer, I specified --restart unless-stopped which doesn’t restart Portainer if it is stopped when restarting docker or when rebooting.

docker run -d -p 9000:9000 --name portainer --restart unless-stopped ...

This doesn’t work with nethserver-discourse.

nethserver-discourse

# docker --version
Docker version 19.03.8, build afacb8b
#

# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                              NAMES
64509fecbe76        portainer/portainer-ce   "/portainer --ssl --…"   14 seconds ago      Up 7 seconds        8000/tcp, 0.0.0.0:9000->9000/tcp   portainer
491eb1ce652a        local_discourse/app      "/sbin/boot"             24 hours ago        Up 9 minutes                                           app
#

# docker stop portainer
portainer
#

# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                     PORTS               NAMES
64509fecbe76        portainer/portainer-ce   "/portainer --ssl --…"   33 seconds ago      Exited (2) 6 seconds ago                       portainer
491eb1ce652a        local_discourse/app      "/sbin/boot"             24 hours ago        Up 9 minutes                                   app
#

Portainer is stopped (Exited).

# systemctl restart docker
#

# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS              PORTS                              NAMES
64509fecbe76        portainer/portainer-ce   "/portainer --ssl --…"   About a minute ago   Up 4 seconds        8000/tcp, 0.0.0.0:9000->9000/tcp   portainer
491eb1ce652a        local_discourse/app      "/sbin/boot"             24 hours ago         Up 10 minutes                                          app
#

Portainer is restarted (Up) with a restart of docker.


Standard Discourse

# docker --version
Docker version 20.10.7, build f0df350
#

# docker ps -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED      STATUS         PORTS                                                 NAMES
150b4ba20533   portainer/portainer-ce   "/portainer --ssl --…"   2 days ago   Up 2 minutes   8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp   portainer
7eb2109d5c9a   local_discourse/app      "/sbin/boot"             2 days ago   Up 2 minutes                                                         app
#

# docker stop portainer
portainer
#

# docker ps -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED      STATUS                     PORTS     NAMES
150b4ba20533   portainer/portainer-ce   "/portainer --ssl --…"   2 days ago   Exited (2) 9 seconds ago             portainer
7eb2109d5c9a   local_discourse/app      "/sbin/boot"             2 days ago   Up 2 minutes                         app
#

Portainer is stopped (Exited).

# systemctl restart docker
#

# docker ps -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED      STATUS                      PORTS     NAMES
150b4ba20533   portainer/portainer-ce   "/portainer --ssl --…"   2 days ago   Exited (2) 32 seconds ago             portainer
7eb2109d5c9a   local_discourse/app      "/sbin/boot"             2 days ago   Up 6 seconds                          app
#

When I restart DOCKER, Portainer is not started, it is still (Exited).

I used the exact same command to create Portainer on both servers.

Maybe the version of Docker: 19.03.8, build afacb8b vs 20.10.7, build f0df350 ?
41327C5 builds apart ?

Michel-André

did you install portainer with nethserver-docker or manually ?

Salut @stephdl,

I installed manually.

Michel-André

why manually ?

with nethserver-docker do

config setprop portainer status enabled
signal-event nethserver-docker-update

To have the latest version.

Michel-André

Screenshot - 2021-07-07T181118.347

does it sound good for you, I just installed yet portainer on my nethserver-docker

It is a container, just delete the old portainer container then build it again

[root@firewall ~]# docker rm -f portainer
portainer
[root@firewall ~]# docker ps
CONTAINER ID   IMAGE                  COMMAND      CREATED       STATUS                 PORTS                            NAMES
54bdc613b09e   pihole/pihole:latest   "/s6-init"   7 weeks ago   Up 7 weeks (healthy)   53/udp, 53/tcp, 80/tcp, 67/udp   pihole
[root@firewall ~]# systemctl restart docker
[root@firewall ~]# docker ps
CONTAINER ID   IMAGE                  COMMAND      CREATED       STATUS                 PORTS                            NAMES
54bdc613b09e   pihole/pihole:latest   "/s6-init"   7 weeks ago   Up 7 weeks (healthy)   53/udp, 53/tcp, 80/tcp, 67/udp   pihole
[root@firewall ~]# signal-event nethserver-docker-update 
[root@firewall ~]# docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS                 PORTS                            NAMES
9e9828a9601f   portainer/portainer-ce   "/portainer -H unix:…"   16 seconds ago   Up 14 seconds          8000/tcp, 9000/tcp               portainer
54bdc613b09e   pihole/pihole:latest     "/s6-init"               7 weeks ago      Up 7 weeks (healthy)   53/udp, 53/tcp, 80/tcp, 67/udp   pihole

maybe you need to drop the image too if you want to get the latest…do not recall it

You have to stop Portainer, then restart Docker to see if Portainer is UP our Exited.

Michel-André

@mrmarkuz for pihole I have some wrapper to ease the docker side, and a pihole update

https://github.com/stephdl/nethserver-pihole/blob/ns7/root/usr/bin/pihole#L38

do you think it could be valuable ?

the default portainer container works as you expect

[root@firewall ~]# docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS                 PORTS                            NAMES
9e9828a9601f   portainer/portainer-ce   "/portainer -H unix:…"   5 minutes ago   Up 5 minutes           8000/tcp, 9000/tcp               portainer
54bdc613b09e   pihole/pihole:latest     "/s6-init"               7 weeks ago     Up 7 weeks (healthy)   53/udp, 53/tcp, 80/tcp, 67/udp   pihole
[root@firewall ~]# docker stop portainer 
portainer
[root@firewall ~]# docker ps
CONTAINER ID   IMAGE                  COMMAND      CREATED       STATUS                 PORTS                            NAMES
54bdc613b09e   pihole/pihole:latest   "/s6-init"   7 weeks ago   Up 7 weeks (healthy)   53/udp, 53/tcp, 80/tcp, 67/udp   pihole
[root@firewall ~]# 
[root@firewall ~]# systemctl restart docker
[root@firewall ~]# docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS                 PORTS                            NAMES
9e9828a9601f   portainer/portainer-ce   "/portainer -H unix:…"   5 minutes ago   Up 2 seconds           8000/tcp, 9000/tcp               portainer
54bdc613b09e   pihole/pihole:latest     "/s6-init"               7 weeks ago     Up 7 weeks (healthy)   53/udp, 53/tcp, 80/tcp, 67/udp   pihole
[root@firewall ~]#

I do not know or use pihole.

Michel-André

--restart always \

:confused:

I use --restart unless-stopped to save memory and CPU utilization because Discourse is quite heavy on memory/CPU.

Michel-André

I really do not understand sorry I cannot help

After stopping Portainer, it liberates memory and doesn’t take any CPU any more.

Later, if you need Portainer, you just start it and, when finish, you stop it.

--restart always will always keep Portainer running, no matter if you use it or not.

Michel-André

no Do not automatically restart the container. (the default)
on-failure Restart the container if it exits due to an error, which manifests as a non-zero exit code.
always Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. (See the second bullet listed in restart policy details)
unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.

there is not much option, all are there I think, but I am not a master of docker :frowning: