Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Killing a Process in a Running Docker Container

Tags:

docker

I have a server-side application running in a Docker container. One of the processes in it has hung and needs to be killed (the application will then spawn another process to replace it).

Is there any way to kill that process without stopping the Docker container?

like image 292
Tania Ang Avatar asked Dec 16 '13 15:12

Tania Ang


People also ask

How do I kill a process in docker container?

To kill a container you use docker kill command and pass the container ID. You can pass any Unix signal when calling the kill command. When you kill a container you can start it again just like you start a container that was properly stopped.

How do you stop a container process?

To stop one or more running Docker containers, you can use the docker stop command. The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...] You can specify one or more containers to stop.

What is the difference between kill and stop in docker?

To terminate a container, Docker provides the docker stop and docker kill commands. Both the docker kill and docker stop commands look similar, but their internal execution is different. The docker stop commands issue the SIGTERM signal, whereas the docker kill commands sends the SIGKILL signal.


1 Answers

It is not possible with Docker for now, but seems to be scheduled for 0.8, see issue #1228 here.

It is however possible to use lxc-attach to run a shell in an existing container (seen in the above issue comments) and you then can kill your hung process from there :

 $ lxc-attach -n FULLCONTAINERID /bin/bash
like image 102
ometra Avatar answered Sep 28 '22 05:09

ometra