I used this answer as a guide to help me writer a startup script for systemd to start my Jenkins container when my machine boots up. However, the script is not working. Here is the script:
[Unit]
Description=Docker container that houses the Jenkins build service.
After=network-online.target
[Service]
Group=docker
ExecStart=/usr/bin/docker start jenkins
ExecStop=/usr/bin/docker stop jenkins
[Install]
WantedBy=multi-user.target
I placed it in /etc/systemd/system/jenkins.service
.
When I run sudo systemctl start jenkins
, nothing happens. No errors or anything printed out, and the container does not start (if I run docker ps
, there are no containers listed as running).
I can run /usr/bin/docker start jenkins
from the command line manually and it starts perfectly fine, so the issue seems to be in the way I've written the script, but I can't figure out why it's not working as expected. Any help is appreciated.
ExecStart=/bin/sh -c "/usr/bin/docker start jenkins"
– Panther Dec 01 '17 at 02:04sudo systemctl stop jenkins
and then tried to start it again and it would no longer start. Not sure why... – wheeler Dec 02 '17 at 22:34