I'm running some services through docker-compose, and launching them with systemd:
$ systemctl status nextcloud.service
● nextcloud.service - HomelabOS nextcloud Service
Loaded: loaded (/etc/systemd/system/nextcloud.service; enabled; vendor preset: disabled)
Active: deactivating (stop-sigterm) since Wed 2021-12-08 23:49:07 EST; 5min ago
Process: 402260 ExecStop=/usr/bin/docker-compose -f /var/homelabos/docker-compose.nextcloud.yml -p nextcloud stop (code=exited, status=0/SUCCES>
Main PID: 3128 (docker-compose)
Tasks: 22 (limit: 38376)
Memory: 12.8M
CPU: 8.704s
CGroup: /system.slice/nextcloud.service
└─3128 /usr/bin/docker-compose -f /var/homelabos/docker-compose.nextcloud.yml -p nextcloud up --build
...
As you can see, the containers have been killed successfully, and other commands say the same thing:
$ sudo /usr/bin/docker-compose -f /var/homelabos/docker-compose.nextcloud.yml -p nextcloud ps
NAME COMMAND SERVICE STATUS PORTS
nextcloud-nextcloud-1 "/entrypoint.sh /usr…" nextcloud exited (137)
nextcloud-nextcloud_db-1 "docker-entrypoint.s…" nextcloud_db exited (0)
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
363f0b6c5e24 grafana/grafana "/run.sh" 2 minutes ago Up 2 minutes 3000/tcp grafana-grafana-1
The problem here is that docker-compose up
is still running! How do I get it to stop doing that, and instead stop when the containers it manages are stopped, i.e. the original behavior?
-d
flag?-d
, that no longer happens.