File | Purpose |
---|---|
/etc/compose/docker-compose.yml |
Compose file describing what to deploy |
/etc/systemd/system/docker-compose-reload.service |
Executing unit to trigger reload on docker-compose.service |
/etc/systemd/system/docker-compose-reload.timer |
Timer unit to plan the reloads |
/etc/systemd/system/docker-compose.service |
Service unit to start and manage docker compose |
Put the above mentioned files in the corresponding places and let systemd load them:
# systemctl daemon-reload
# systemctl enable --now docker-compose.service docker-compose-reload.timer
The method shown here is also available as an Ansible role here: luzifer-ansible/docker-compose
Note: there is one quirk with that pattern that has been a problem for me: if the
ExecStartPre
command fails, then the service is failed forever and will never start (Restart=
is not supported ononeshot
services, see systemd/systemd#2582).I don't have a convincing alternative to offer though, maybe changing
reload
intoreload-or-restart
in the timer, at least it would be restarted periodically if it fails.