-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
SIGTERM
sent to docker run
command doesn't send a SIGTERM to the main process running inside the container anymore.
#5241
Comments
It seems like we aren't forwarding signals to the container. Or maybe exiting the CLI before they are forwarded. I'll take a look in a bit |
I looked into this and it seems that the container is being terminated correctly. Although it could happen to have a race condition which could end up terminating the CLI before an event is forwarded to the daemon. From the output you received it looks confusing since the CLI is being terminated before the script can output its own output (which gets printed by the CLI). There are two processes, the CLI and the container.
When we send a termination signal to the CLI we do the following:
You can see in this log console output I've added a log inside
I'll take a look at how this can be improved so we can wait for the container to be killed before detaching and exiting the main CLI process. |
Thanks for looking into this. The container is indeed being terminated properly - The main problem is that, in production, the process running inside the container often have cleanup routines to run when receiving specific signals like |
Description
In Docker version
26.1.4
, sending a SIGTERM to thedocker run
process would also send a SIGTERM to the main process inside the container. However, in version27.0.3
, this behavior has changed. Now, the process exits with the messagecontext canceled
without the main process receiving a SIGTERM.Reproduce
pid
of this process as follows (in a separate terminal) and send a sigtermExpected behavior
Up until version
26.x
, the SIGTERM would be received by the main process and it would output the following:docker version
Client: Docker Engine - Community Version: 27.0.3 API version: 1.46 Go version: go1.21.11 Git commit: 7d4bcd8 Built: Sat Jun 29 00:02:33 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 27.0.3 API version: 1.46 (minimum version 1.24) Go version: go1.21.11 Git commit: 662f78c Built: Sat Jun 29 00:02:33 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.18 GitCommit: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e runc: Version: 1.7.18 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
Tried in both Ubuntu 20 and Ubuntu 22 with Docker
26.1.4
and Docker27.0.3
.The text was updated successfully, but these errors were encountered: