Docker-compose no longer gracefully stops
Expected behavior
Successful graceful shutdown of docker-compose
Actual behavior
All containers are stopped, but compose is hanging on forever until we are forced to kill it.
Gracefully stopping... (press Ctrl+C again to force)
[+] Running 7/7
⠿ Container PRJ-dev_spark-worker_1 Stopped 11.3s
⠿ Container PRJ-dev_spark-master_1 Stopped 12.2s
⠿ Container PRJ-dev_kafka-schemaregistry_1 Stopped 11.3s
⠿ Container PRJ-dev_mongodb_1 Stopped 12.3s
⠿ Container PRJ-dev_object-storage_1 Stopped 1.7s
⠿ Container PRJ-dev_kafka_1 Stopped 4.3s
⠿ Container PRJ-dev_zookeeper_1 Stopped 11.4s
(hanging forever ...)
^CERRO[3631] got 3 SIGTERM/SIGINTs, forcing shutdown
[+] Running 0/0
⠿ Container PRJ-dev_mongodb_1 Error while Killing 0.0s
⠿ Container PRJ-dev_spark-worker_1 Error while Killing 0.0s
⠿ Container PRJ-dev_object-storage_1 Error while Killi... 0.0s
⠿ Container PRJ-dev_spark-master_1 Error while Killing 0.0s
⠿ Container PRJ-dev_kafka-schemaregistry_1 Error while... 0.0s
⠿ Container PRJ-dev_kafka_1 Error while Killing 0.0s
⠿ Container PRJ-dev_zookeeper_1 Error while Killing
Information
- macOS Version: 10.15.7
- Intel core i7
- Docker Desktop version: 3.5.1 (3.5.1.7)
- Docker Compose version: 2.0.0-beta.4
Steps to reproduce the behavior
- On a fresh Docker Desktop (after data purge),
docker-compose -f any-conf.yml up - Once everything is up,
Ctrl+Cto gracefully stop
What is your compose version please? (docker-compose version)
Docker Compose version 2.0.0-beta.4, the one coming with this Docker Desktop
Thanks, in that case I'll move this into the docker/compose-cli repo.
Hi there! Do you have a docker compose file that we can use to reproduce the issue?
Whatever is the compose file the issue happens
I can't reproduce this issue. Can you confirm you get this issue even with a minimal compose file?
services:
test:
image: nginx
As said, whatever compose, even single service, it exhibit the issue (doubt it was a good idea to include a beta version of compose in Docker desktop ...).
version: "3.6"
services:
mongodb:
image: mongo
restart: on-failure:5
ports:
- 27017
environment:
MONGO_INITDB_DATABASE: foo
Ok, I can confirm this issue is reproducible once the service is set with restart: on-failure
internally tracked as https://docker.atlassian.net/browse/IL-397
This also occurs on my machine; same setup as OP, latest Docker Desktop on Mac. This is pretty annoying.

Still not fix. I can hardly lobby for the new Docker plan with such issues.
Have you tried using v2.2.0? AFAICT this has been fixed by https://github.com/docker/compose/pull/8926
I'm still seeing this error with v2.2.0 on Linux.
$ docker-compose --version
Docker Compose version 2.2.0
$ docker --version
Docker version 20.10.11, build dea9396e18
^CGracefully stopping... (press Ctrl+C again to force)
[+] Running 2/2
⠿ Container app-core-app_core-1 Stopped 0.3s
⠿ Container app-core-postgres-1 Stopped 0.3s
[+] Running 0/0
⠿ Container app-core-app_core-1 Error while Killing 0.0s
⠿ Container app-core-postgres-1 Error while Killing
Seeing the same issue as @mofux here, I have to kill -9 the docker-compose process
$ docker-compose --version
Docker Compose version 2.2.0
$ docker --version
Docker version 20.10.11, build dea9396e18
update:
My docker-compose contains one service with restart: always (a postgresql database) and when I remove the restart: always attribute from the service, docker-compose does not hang when shutting down.
Minimal reproducable example on my system:
version: '3.9'
services:
db:
image: postgres:13-alpine
restart: always
env_file:
- .db.env
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data:
Causes docker-compose to hang after Ctrl-C (only kill -9 helps here):
^CGracefully stopping... (press Ctrl+C again to force)
[+] Running 1/1
⠿ Container docker-compose-test-db-1 Stopped 0.3s
[+] Running 0/0
⠿ Container docker-compose-test-db-1 Error while Killing 0.0s
Removing restart: always, docker-compose shuts down correctly:
^CGracefully stopping... (press Ctrl+C again to force)
[+] Running 1/1
⠿ Container docker-compose-test-db-1 Stopped 0.3s
canceled
Would be happy to provide further details if needed, @ndeloof.
Having the same issue with docker compose since I updated Docker Desktop for Mac from 4.2 to 4.3. All container stopped successfully, but the command is hanging then and forcing the shutdown then produces output Error while Killing for every container.
- Docker Compose version v2.2.1
- Docker version 20.10.11, build dea9396
Edit: Downgrading to Docker Desktop 4.2 is my temporarily workaround.
Having the same with Compose 2.2.2 and Docker 20.10.11 on Archlinux.
+1, Similar issue with Docker Desktop for Windows 4.3.
Same here on MacOS:

+1 same problem after upgrading to docker 20.10.12 and docker-compose 2.2.2 (on a archlinux machine).
+1 same problem here with ubuntu 20.4.3, docker-ce 20.10.12 and docker-compose 2.2.2. Ctrl-C doesn't stop compose if run without -d. Downgrade to 1.29.2 solved it