"docker run" cannot be killed with ctrl+c

So there are two factors at play here:

  1. If you specify a string for an entrypoint, like this:

    ENTRYPOINT /go/bin/myapp

Docker runs the script with /bin/sh -c 'command'. This intermediate script gets the SIGTERM, but doesn’t send it to the running server app.

To avoid the intermediate layer, specify your entrypoint as an array of strings.

ENTRYPOINT ["/go/bin/myapp"]
  1. I built the app I was trying to run with the following string:

    docker build -t first-app .

This tagged the container with the name first-app. Unfortunately when I tried to rebuild/rerun the container I ran:

docker build .

Which didn’t overwrite the tag, so my changes weren’t being applied.

Once I did both of those things, I was able to kill the process with ctrl+c, and bring down the running container.

3 Likes