Docker Community Forums

Share and learn in the Docker community.

Docker containers fail to start at reboot

Here is the systemd file;
[Unit]
Description=NZBGet container
Requires=docker.service
After=docker.service

[Service]
ExecStart=/usr/bin/docker run -p 6789:6789 --name=nzbget --restart=always -e PUID=1000 -e PGID=1000 -e /etc/localtime:/etc/localtime:gb -v /opt/nzbget:/config -v /mnt:/Downloads lsioarmhf/nzbget
ExecStop=/usr/bin/docker stop -t 2 nzbget
ExecStopPost=/usr/bin/docker rm -f nzbget

[Install]
WantedBy=default.target

and the output of sudo systemctl status nzbget
$ sudo systemctl status nzbget -l
* nzbget.service - NZBGet container
Loaded: loaded (/etc/systemd/system/nzbget.service; enabled)
Active: failed (Result: exit-code) since Sat 2016-12-03 12:20:38 GMT; 41s ago
Process: 1964 ExecStopPost=/usr/bin/docker rm -f nzbget (code=exited, status=0/SUCCESS)
Process: 1497 ExecStop=/usr/bin/docker stop -t 2 nzbget (code=exited, status=0/SUCCESS)
Process: 1311 ExecStart=/usr/bin/docker run -p 6789:6789 --name=nzbget --restart=always -e PUID=1000 -e PGID=1000 -e /etc/localtime:/etc/localtime:gb -v /opt/nzbget:/config -v /mnt:/Downloads lsioarmhf/nzbget (code=exited, status=125)
Main PID: 1311 (code=exited, status=125)

Dec 03 12:20:30 osmc systemd[1]: Started NZBGet container.
Dec 03 12:20:31 osmc docker[1311]: /usr/bin/docker: Error response from daemon: Conflict. The name "/nzbget" is already in use by container 1c84c92746c11d519e26b876b57efe4630c249046883715388373db488c84465. You have to remove (or rename) that container to be able to reuse that name..
Dec 03 12:20:31 osmc docker[1311]: See '/usr/bin/docker run --help'.
Dec 03 12:20:31 osmc systemd[1]: nzbget.service: main process exited, code=exited, status=125/n/a
Dec 03 12:20:35 osmc docker[1497]: nzbget
Dec 03 12:20:38 osmc docker[1964]: nzbget
Dec 03 12:20:38 osmc systemd[1]: Unit nzbget.service entered failed state

Hi,

I got the same problem you have, I solved by replacing the “docker run” command by a “docker start”.

Once your container is created with a name, you may start/stop it from the .service file. You should simply replace:

ExecStart=/usr/bin/docker run -p 6789:6789 --name=nzbget --restart=always -e PUID=1000 -e PGID=1000 -e /etc/localtime:/etc/localtime:gb -v /opt/nzbget:/config -v /mnt:/Downloads lsioarmhf/nzbget

by:

ExecStart=/usr/bin/docker start -a nzbget

All the port forwarding are started as expected, as it uses the same container you created (using the docker run command).

Hope it helps.

1 Like