Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping stubborn container?

Tags:

docker

I have a container open attached to a terminal, but ctrl+C and crtl+D are not working to stop it. Ergo, I opened another terminal and tried

docker stop CONTAINER_ID

where CONTAINER_ID is the ID of the container that is hung. This did not work, and hung that terminal. So I did a little internet research which led me to try

docker kill CONTAINER_ID

in another terminal. This also hung. So I searched a little more and found

docker rm -fv CONTAINER_ID

This, unfortunately, just hung in a fourth terminal. Is there a way to shut it down through docker that I'm missing, or do I need to start kill -9ing the processes with "docker" in their description?

I'm running Docker version 17.03.0-ce, build 60ccb22 on OSX.

like image 741
wogsland Avatar asked Mar 14 '17 19:03

wogsland


People also ask

How do you stop a container from forcefully?

docker rm -f The final option for stopping a running container is to use the --force or -f flag in conjunction with the docker rm command. Typically, docker rm is used to remove an already stopped container, but the use of the -f flag will cause it to first issue a SIGKILL.

How do you stop a container from running?

Note that pressing `Ctrl+C` when the terminal is attached to a container output causes the container to shut down. Use `Ctrl+PQ` in order to detach the terminal from container output.

What command will stop a docker container?

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.

How do I get rid of docker forcefully?

To remove one or more Docker containers, use the docker container rm command, followed by the IDs of the containers you want to remove. If you get an error message similar to the one shown below, it means that the container is running. You'll need to stop the container before removing it.


Video Answer


1 Answers

When docker hangs like that, I usually just restart the daemon and the clients will disconnect. On MacOS, that involves going to the whale drop down and running the restart from there. I often need to do this if my IP address changes.

Also, not relevant to you but may help others in the future, on earlier versions of docker (before 17.03) there is a deadlock issue especially with logs that would cause commands to hang. The solution is the same, restarting docker, but in this case I'd also recommend upgrading.

like image 152
BMitch Avatar answered Oct 18 '22 05:10

BMitch