Fix ctrl-c not propagating to the containers for a 'docker run' on Windows#3302
Fix ctrl-c not propagating to the containers for a 'docker run' on Windows#3302thaJeztah merged 2 commits intodocker:masterfrom mat007:win-fix-signals
Conversation
vendor.conf
Outdated
| github.com/mitchellh/mapstructure d16e9488127408e67948eb43b6d3fbb9f222da10 # v1.3.2 | ||
| github.com/moby/buildkit 9f254e18360a24c2ae47b26f772c3c89533bcbb7 # master / v0.9.0-dev | ||
| github.com/moby/sys 9b0136d132d8e0d1c116a38d7ec9af70d3a59536 # signal/v0.5.0 (latest tag, either mount/vXXX, mountinfo/vXXX, signal/vXXX, or symlink/vXXX) | ||
| github.com/moby/sys 76a42cd566e5f05c3155179ea779e418df4ff4f9 # master (either mount/vXXX, mountinfo/vXXX, signal/vXXX, or symlink/vXXX) |
There was a problem hiding this comment.
I’m not sure what the comment inside the brackets means 😬
Also maybe we’d want a new released version of moby/sys eventually?
There was a problem hiding this comment.
The github.com/moby/sys repository is a collection of modules, and each is versioned separately. So when using go modules, you need to use one (or more) of;
github.com/moby/sys/mount@<version>github.com/moby/sys/mountinfo@<version>github.com/moby/sys/signal@<version>github.com/moby/sys/symlink@<version>
The cli doesn't yet use go modules, so we're vendoring the "root" of moby/sys, but want to match a tagged release if possible (so that we would match whatever someone would be using when using go modules).
I think there may be one or two changes left to make in the github.com/moby/sys/signal module, and after that we can do a new release.
Let me have a look at that, and perhaps we can have those in before we merge this.
Note that the 20.10 branch does not yet use github.com/moby/sys/signal, but uses the same package (which used to be in https://github.com/moby/moby, so if we need this for the docker 20.10 cli, we may need to either update the package in moby/moby, or backport the migration to the new package 😓
There was a problem hiding this comment.
I think there may be one or two changes left to make in the
github.com/moby/sys/signalmodule
Any details there? I don’t see any related pending issue or PR in that repo.
There was a problem hiding this comment.
It took a bit longer, as some fixes for k8s were pending, but I just tagged signal v0.6.0: https://github.com/moby/sys/releases/tag/signal%2Fv0.6.0
Can you change this to:
| github.com/moby/sys 76a42cd566e5f05c3155179ea779e418df4ff4f9 # master (either mount/vXXX, mountinfo/vXXX, signal/vXXX, or symlink/vXXX) | |
| github.com/moby/sys 03b9f8d59a07f5206a2264105f4903a222aea964 # signal/v0.6.0 (latest tag, either mount/vXXX, mountinfo/vXXX, signal/vXXX, or symlink/vXXX) |
And re-vendor? (please squash the commits if needed)
Codecov Report
@@ Coverage Diff @@
## master #3302 +/- ##
=======================================
Coverage 57.99% 57.99%
=======================================
Files 302 302
Lines 21764 21764
=======================================
Hits 12621 12621
Misses 8219 8219
Partials 924 924 |
|
This PR doesn’t seem to fix all cases, for instance the one described in docker-archive/compose-cli#1151 (comment) doesn’t work on Windows (unless I think the problem has to do with using The signal does go through the ForwardAllSignals function and calls with I’m not sure how to track further, given it works properly on Mac. 🤔 |
|
Oh wait, it actually works fine using cmd and powershell. Prefixing with |
|
@thaJeztah can I help unblocking this PR in some way? |
|
Also, shouldn't SIGINT be presented to the container's main process and the behavior be generated from there? And some processes (like mysql) don't care, want other signals. |
This adds a Windows TERM signal which makes propagation of termination to containers work properly. Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
- What I did
I fixed
docker runhanging after a ctrl-c on Windows.- How I did it
I bumped the vendoring to
moby/systo add many more signal definitions for Windows, includingTERM.- How to verify it
Running
docker run nginxand hitting ctrl-c was hanging before the fix.After the fix it exits and a
docker ps -ashows the container has been exited.- Description for the changelog
Fixed ctrl-c hanging on Windows to exit after running a container in non-interactive mode.
- A picture of a cute animal (not mandatory but encouraged)
(sorry if this was posted before, I’m new at this)