2

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?

3
  • 1
    Can't you use -d flag?
    – pLumo
    Commented Dec 9, 2021 at 7:21
  • I also need it to print the containers' logs to stdout so it is picked up by syslog. With -d, that no longer happens.
    – flaviut
    Commented Dec 9, 2021 at 15:34
  • 1
    I noticed that in my version it gets "stuck" running even after I Ctrl-C on the command line, and all containers are reported as "stopped". I have begun to suspect that this might be a bug in Docker Compose. Commented Dec 9, 2021 at 18:04

1 Answer 1

2

This is a bug in docker compose v2.2.0. Downgrading to v2.1.1 should fix the issue.

It now also appears to be fixed in v2.2.3.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .