Create a file /etc/systemd/system/myservice.service
Enable the service:
systemctl enable myservice
Then:
service myservice startservice myservice statusservice myservice stop- etc.
Re-read system config files:
systemctl daemon-reload
| [Unit] | |
| Description=Service Name | |
| Requires=docker.service | |
| After=docker.service | |
| [Service] | |
| User=username | |
| Type=oneshot | |
| RemainAfterExit=yes | |
| WorkingDirectory=/path/to/directory | |
| ExecStart=/usr/local/bin/docker-compose up -d | |
| ExecStop=/usr/local/bin/docker-compose down | |
| [Install] | |
| WantedBy=multi-user.target |