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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 14
  • Comments: 32 (1 by maintainers)

Most upvoted comments

Hello everybody,

Sorry for the “end of the year delay”. This issue has been fixed by #9019 and version 2.2.3 will be released soon.

@designermonkey This will be included in the next version of Docker Desktop.

Same here on MacOS: image

+1 same problem

OS: Windows 10 Docker Engine v20.10.11 Docker Compose v2.2.1 Docker Desktop Docker Desktop 4.3.2 (72729) Using WSL 2

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

docker compose up never closes. If I do Cntrl+C twice its shows Error while killing and never exits.

[+] Running 6/6
 ⠿ Container dev_manager  Stopped                                                                                                               0.0s
 ⠿ Container dev_mongo    Stopped                                                                                                               0.5s
 ⠿ Container eproduct     Stopped                                                                                                               0.5s
 ⠿ Container dev_master   Stopped                                                                                                               0.0s
 ⠿ Container esearch      Stopped                                                                                                              10.3s
 ⠿ Container dev_redis    Stopped                                                                                                               0.4s
[+] Running 0/0
 ⠿ Container esearch      Error while Killing                                                                                                   0.0s
 ⠿ Container dev_mongo    Error while Killing                                                                                                   0.0s
 ⠿ Container dev_redis    Error while Killing                                                                                                   0.0s
 ⠿ Container dev_manager  Error while Killing                                                                                                   0.0s
 ⠿ Container eproduct     Error while Killing                                                                                                   0.0s
 ⠿ Container dev_master   Error while Killing                                                                                                   0.0s

Using Arch Linux with kernel 5.15.12-arch1-1 docker: 20.10.12, build e91ed5707e docker-compose: 2.2.2

I face the same problem in Manjaro. docker-compose.yml

version: "3.7"

services:
  api-dev:
    image: ${COMPOSE_PROJECT_NAME}-dev:latest
    container_name: "${COMPOSE_PROJECT_NAME}-dev-${APP_NAME}"
    restart: always
    volumes:
      - type: bind
        source: .
        target: /app
        volume:
          nocopy: true
    build:
      context: .
      dockerfile: ./dev.Dockerfile
    ports:
      - "${APP_PORT}:${APP_PORT}"
      - "${DEBUGGING_PORT}:${DEBUGGING_PORT}"
    environment:
      NODE_ENV: development
    env_file:
      - ./.env

and Dockerfile

# Installation stage
FROM node:16.13-alpine as copy_stage

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm config set registry https://registry.npmjs.org/ && npm config set maxsockets 20
RUN npm ci --loglevel verbose

# Creating isolated image with the installed pacakges inside node_modules
FROM node:16.13-buster

RUN mkdir -p /app && chown -R 1000:1000 /app

WORKDIR /app

ENV NODE_PATH=/usr/local/lib/node_modules/

COPY --chown=1000:1000 --from=copy_stage /app .

EXPOSE ${APP_PORT}
EXPOSE ${DEBUGGING_PORT}

USER 1000:1000

CMD [ "npm", "run", "start:dev" ]

docker version command output:

Client:
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.17.3
 Git commit:        dea9396e18
 Built:             Sat Nov 20 12:57:52 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.3
  Git commit:       847da184ad
  Built:            Sat Nov 20 12:57:08 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.5.8
  GitCommit:        1e5ef943eb76627a6d3b6de8cd1ef6537f393a71.m
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

uname -a command output:

Linux kasir 5.10.84-1-MANJARO #1 SMP PREEMPT Wed Dec 8 09:50:30 UTC 2021 x86_64 GNU/Linux

My docker container up and run successfully but It cannot stop containers gracefully and I have to press ctrl + c twice.

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

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

@ulyssessouza will this create a new update for Docker Desktop (Mac) as mine says it is fully up to date (4.3.2 (72729)) yet only has v2.2.1 for docker compose?

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 

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