Docker Container won't start with systemctl Docker Container won't start with systemctl docker docker

Docker Container won't start with systemctl


You are running redis container in detached mode so docker utility starts container and then exits. From systemd point of view this looks like controlled process exited so systemd executes ExecStop script which in your case stops redis container.

You need to keep process running so systemd won't try to stop or restart your container. One way to achieve this is to remove --detach flag. You can also use KillMode=none so systemd won't send SIGTERM to docker utility but will execute only ExecStop instead.

[Unit]Requires=docker.serviceAfter=docker.service[Service]TimeoutStartSec=0KillMode=noneRestart=alwaysRestartSec=5sExecStartPre=-/usr/bin/docker kill %pExecStartPre=-/usr/bin/docker rm -v %pExecStart=/usr/bin/docker --name=redis --publish=6379:6379 redisExecStop=/usr/bin/docker stop %pExecStopPost=-/usr/bin/docker stop %p