Skip to content

Docker-compose v2.3+ stops all containers when pressing Ctrl + c #9287

@Zesko

Description

@Zesko

Description

I noticed the issue after the upgrade of docker-compose from v2.2.3 to v2.3.3 or newer:
I want to stop the nignx-proxy container after docker-compose -f nginx-proxy.yml up
But pressing CTRL+C stops all containers (when they are in my same sub-network).

[+] Running 1/0
 ⠿ Container nginx_proxy  Created                                                                                                                                                                                                   0.0s
Attaching to test_db_edc_mzl-1, test_db_form_mdr-1, test_db_keycloak-1, test_edc-1, test_formeditor-1, test_keycloak-1, test_mdr-1, test_mzl-1, nginx_proxy
...
# Pressing CTRL + C, then:
Gracefully stopping... (press Ctrl+C again to force)
[+] Running 9/9
 ⠿ Container test_keycloak-1     Stopped                                                                                                                                                                                   0.7s
 ⠿ Container test_db_form_mdr-1  Stopped                                                                                                                                                                                   0.4s
 ⠿ Container nginx_proxy         Stopped                                                                                                                                                                                   0.6s
 ⠿ Container test_db_edc_mzl-1   Stopped                                                                                                                                                                                   0.5s
 ⠿ Container test_db_keycloak-1  Stopped                                                                                                                                                                                   0.6s
 ⠿ Container test_edc-1          Stopped                                                                                                                                                                                  10.4s
 ⠿ Container test_formeditor-1   Stopped                                                                                                                                                                                  10.3s
 ⠿ Container test_mdr-1          Stopped                                                                                                                                                                                  10.3s
 ⠿ Container test_mzl-1          Stopped 

Downgrade to the old version 2.2.3 that does not have this issue.
It stops only nginx_proxy, not all containers, this is my expectation.

Attaching to nginx_proxy
...
Gracefully stopping... (press Ctrl+C again to force)
[+] Running 1/1
 ⠿ Container nginx_proxy  Stopped                                                                                                                                                                                                   0.4s
canceled

Steps to reproduce the issue:

  1. Upgrade docker-compose version 2.2.3 to 2.3.3 or newer
  2. docker-compose -f nginx-proxy.yml up
  3. press Ctrl + c
  4. All containers are stopped.

Describe the results you received:

It stops all containers when they are in the same sub-network.

Describe the results you expected:
It should stop only nignx-proxy container.
Or how to disable attaching to the dependencies?

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:

Docker Compose version 2.3.3

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
  compose: Docker Compose (Docker Inc., 2.3.3)

Server:
 Containers: 9
  Running: 8
  Paused: 0
  Stopped: 1
 Images: 55
 Server Version: 20.10.12
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 10f428dac7cec44c864e1b830a4623af27a9fc70.m
 runc version: v1.1.0-0-g067aaf85
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.16.14-1-MANJARO
 Operating System: Manjaro Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.32GiB
 Name: zesko
 ID: 2YPM:WOMX:CJHP:P57S:HIV7:A45H:JXFD:53YZ:WYKL:VXNP:KDSS:HWPQ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions