compose icon indicating copy to clipboard operation
compose copied to clipboard

Docker-compose no longer gracefully stops

Open cchantep opened this issue 5 years ago • 33 comments

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+C to gracefully stop

cchantep avatar Jul 02 '21 12:07 cchantep

What is your compose version please? (docker-compose version)

stephen-turner avatar Jul 05 '21 07:07 stephen-turner

Docker Compose version 2.0.0-beta.4, the one coming with this Docker Desktop

cchantep avatar Jul 06 '21 07:07 cchantep

Thanks, in that case I'll move this into the docker/compose-cli repo.

stephen-turner avatar Jul 06 '21 07:07 stephen-turner

Hi there! Do you have a docker compose file that we can use to reproduce the issue?

lorenrh avatar Jul 06 '21 08:07 lorenrh

Whatever is the compose file the issue happens

cchantep avatar Jul 06 '21 21:07 cchantep

I can't reproduce this issue. Can you confirm you get this issue even with a minimal compose file?

services:
  test:
    image: nginx

ndeloof avatar Jul 12 '21 09:07 ndeloof

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

Screencast

cchantep avatar Jul 12 '21 13:07 cchantep

Ok, I can confirm this issue is reproducible once the service is set with restart: on-failure

ndeloof avatar Jul 12 '21 15:07 ndeloof

internally tracked as https://docker.atlassian.net/browse/IL-397

ndeloof avatar Jul 12 '21 15:07 ndeloof

This also occurs on my machine; same setup as OP, latest Docker Desktop on Mac. This is pretty annoying. Bildschirmfoto 2021-11-16 um 10 54 41

Radiergummi avatar Nov 16 '21 09:11 Radiergummi

Still not fix. I can hardly lobby for the new Docker plan with such issues.

cchantep avatar Nov 27 '21 13:11 cchantep

Have you tried using v2.2.0? AFAICT this has been fixed by https://github.com/docker/compose/pull/8926

ndeloof avatar Nov 27 '21 14:11 ndeloof

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 

mofux avatar Dec 01 '21 17:12 mofux

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.

fvdnabee avatar Dec 03 '21 09:12 fvdnabee

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.

DevDavido avatar Dec 03 '21 13:12 DevDavido

Having the same with Compose 2.2.2 and Docker 20.10.11 on Archlinux.

top4ek avatar Dec 07 '21 10:12 top4ek

+1, Similar issue with Docker Desktop for Windows 4.3.

twitchax avatar Dec 08 '21 05:12 twitchax

Same here on MacOS: image

artursudnik avatar Dec 08 '21 11:12 artursudnik

+1 same problem after upgrading to docker 20.10.12 and docker-compose 2.2.2 (on a archlinux machine).

GiacobboNicola avatar Dec 27 '21 14:12 GiacobboNicola

+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

marcefr avatar Dec 27 '21 20:12 marcefr