当容器停止时 docker-compose up 不会退出

当容器停止时 docker-compose up 不会退出

我通过 docker-compose 运行一些服务,并使用 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
...

正如你所看到的,容器已经被成功杀死,其他命令也说了同样的事情:

$ 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

这里的问题是docker-compose up仍在运行!我如何让它停止这样做,而是在它管理的容器停止时停止,即原始行为?

答案1

相关内容