Skip to content

Instantly share code, notes, and snippets.

@agrawald
Last active February 26, 2024 14:44
Show Gist options
  • Save agrawald/719c406d06387c31bc61ca6acf25a0e2 to your computer and use it in GitHub Desktop.
Save agrawald/719c406d06387c31bc61ca6acf25a0e2 to your computer and use it in GitHub Desktop.
Killing a process inside a docker container

Testing graceful shutdown of a docker container process

  • In order to log into a specific container in a bash shell you have to run following command

docker exec -ti <container id|name> bash

  • The above command will take u to the bash shell, now inside the bash shell search of the command which is running your application, for example, java or node

kill -2 $(pidof node)

  • The above command will kill the process node by sending SIGINT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment