Send SIGTERM/SIGKILL with Ctrl+C

When I’m running console processes on my OS X, I often need to kill the process while it’s running without using docker stop/kill command, but apparently the Ctrl+c combination (as well as Ctrl+z) are not passed to process properly. Has anyone dealt with this problem?

1 Like

Same issue with docker machine for Windows.
Using the vbox docker vm or a remote docker hardware, the ctrl+c doesn’t sigkill the running application.
The same command directly on the docker host works fine : the container terminate itself.

I know this answer is late but for the searchers:

The trick is to use tty and to detach but then also reattach. I. e., attach to the run command that runs with -d and -t.

  docker attach $(docker run -d --rm --network host \
         -t \
         --user $(id -u):$(id -g) \
         -v "/home:/home" \
         -v "/etc/passwd:/etc/passwd:ro" \
         -v "/etc/group:/etc/group:ro" \
         -w $PWD node:latest npx eleventy --serve)

This shows the output from the terminal for as long as it runs, but also responds to Ctrl+c.

credit to Les Hazelwood

I am curious. Can you give me an example when Docker for Mac does not send signals properly? I tried CTRL+C and it worked as I expected.