Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] compose run doesn't forward signals #10586

Closed
raylu opened this issue May 19, 2023 · 2 comments · Fixed by #10633
Closed

[BUG] compose run doesn't forward signals #10586

raylu opened this issue May 19, 2023 · 2 comments · Fixed by #10633
Assignees
Labels

Comments

@raylu
Copy link

raylu commented May 19, 2023

Description

as mentioned in #8549 (comment), this doesn't seem to be working for docker compose (v2). the behavior works fine for docker-compose (v1), though

Steps To Reproduce

I ran @ndeloof's demo (from #8549 (comment)). had to comment some lines first:

$ git diff
diff --git a/demo/Dockerfile b/demo/Dockerfile
index a4058f8..6b4998c 100644
--- a/demo/Dockerfile
+++ b/demo/Dockerfile
@@ -3,9 +3,9 @@ FROM golang:1.18-alpine
 
 RUN apk add --no-cache openssh-client git
 RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
-RUN --mount=type=ssh git clone git@github.com:ndeloof/toolbox.git
+#RUN --mount=type=ssh git clone git@github.com:ndeloof/toolbox.git
 
-RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
+#RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
 
 WORKDIR /app
 EXPOSE 5050
$ docker compose run --rm demo
press Ctrl+C to stop

in another shell,

$ ps x | grep compose
 8584 s000  S+     0:00.04 docker compose run --rm demo
 8585 s000  S+     0:00.02 /Applications/Docker.app/Contents/Resources/bin/com.docker.cli compose run --rm demo
 8587 s000  S+     0:00.03 /Users/raylu/.docker/cli-plugins/docker-compose compose run --rm demo

$ ps o pid,ppid,pgid | grep 858
 8584  9824  8584
 8585  8584  8584
 8587  8585  8584
# we see that all 3 processes are in the 8584 process group and we can signal them all at once

$ kill -- -8584
# nothing happens in the first shell

$ kill -- -8584

$ kill -- -8584
# ERRO[0123] got 3 SIGTERM/SIGINTs, forcing shutdown

$ docker ps
CONTAINER ID   IMAGE       COMMAND                  CREATED          STATUS        PORTS    NAMES
2f7a7691c1e3   truc-demo   "/demo"                  3 minutes ago    Up 3 minutes  5050/tcp truc_demo_run_bf3852cbe6ea

Compose Version

$ docker compose version
Docker Compose version v2.15.1

signals are forwarded just fine with v1 (docker-compose)

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc., v2.3.3)

Server:
 Containers: 10
  Running: 0
  Paused: 0
  Stopped: 10
 Images: 27
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Ubuntu 20.04.6 LTS
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 19.52GiB
 Name: f62ba7ef2a4e
 ID: 24DZ:HGLP:2C7U:YTOU:M7RV:OI2I:JNTY:3SW2:3BVM:WJEY:PC3B:P4IE
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 24
  Goroutines: 40
  System Time: 2023-05-19T18:27:21.05660293Z
  EventsListeners: 0
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  registry:5005
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

Anything else?

ndeloof's repro project is at https://github.com/ndeloof/truc

@ndeloof
Copy link
Contributor

ndeloof commented May 30, 2023

I can reproduce, while I hardly can explain this...
I wonder how Ctrl+C on (parent) console differs from sending kill -2 to the docker command.

@ndeloof
Copy link
Contributor

ndeloof commented May 30, 2023

I wonder how Ctrl+C on (parent) console differs from sending kill -2 to the docker command.
update: eventually understood the magic behind setRawTerminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants