(Intermediate) If running the docker image in foreground, sending a kill signal doesn't stop the container
See original GitHub issueTo recreate the problem that exists today:
- run
docker pull supertokens/supertokens-mysql:2.4
- Start the docker image in foreground:
docker run -p 3567:3567 supertokens/supertokens-mysql:2.4
- Wait for it to start… It should display
Started SuperTokens on 0.0.0.0:3567 with PID: <some PID>
- Now send the kill signal (Ctrl + C / Z on a Mac)
At this point, the Java process in the docker process should stop and the docker process itself should quit. However, that does not happen.
The docker file for the above image can be found in this repo. Please feel free to fork that as well.
As some extra info:
- if not using docker (manually installing it on your system), sending the kill signal does stop the running process.
- In the Java code (this repo), in Main.java, there is a function that registers a shutdown hook.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (14 by maintainers)
Top Results From Across the Web
Trapping signals in Docker containers | by Grigorii Chudnov
A docker command `docker kill` used to send a signal to the main process inside a container. Usage: docker kill [OPTIONS] CONTAINER [CONTAINER.....
Read more >"docker run" cannot be killed with ctrl+c
Docker runs the script with /bin/sh -c 'command' . This intermediate script gets the SIGTERM, but doesn't send it to the running server...
Read more >Docker, Java, Signals and Pid 1 - no42
So when you issue the command kill <pid> you send a SIGTERM to a process. ... and just run it in a Java...
Read more >Why Does My Docker Container Stop? - Tutorial Works
This happens if you run a foreground container (using docker run ), and then press Ctrl+C when the program is running. When this...
Read more >Chapter 5. Working with containers Red Hat Enterprise Linux 8
The podman stop command sends a SIGTERM signal to terminate a running container. If the container does not stop after a defined period...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, answering your questions:
I’ll look into it later today, it should automatically be shaded by gradle however.
According to this SO answer it seems like the preferred way would be to check cgroup since
.dockerenv
could be removed at any moment (read about .dockerinit).What kind of issues are you experiencing? This should trap the sigs sent to bash and recreate them as a kill command for the child’s pid. (So even if starting manually this should have the same behaviour).
Windows script shouldn’t have been changed, just repackaged it on resources for the sake of consistency.
Thank you @Fabricio20 . I’ll test with the docker image once again and let you know what happens 😃