Force Stop Docker Container

This is just a quick note about how to forcefully stop a docker container when simple docker stop isn’t working.

I had a problem few days ago with a container that had a mounted volume. The volume was a windows share mounted with cifs. Due to some network problems, the mount became stuck and the docker service was refusing to stop the container. Running both docker stop or docker kill was not getting me anywhere. I did not want to shutdown the whole docker service since there were other containers running, not affected by the mount problem.

After searching for some time, I stumbled upon this github issue comment with a nice description of an alternative approach which worked nicely. So all credit goes to the fine gentleman that shared it

# 1/ Get the container id
docker ps

# 2/ Get the containerd-shim process id
sudo ps awx | grep containerd-shim | grep <<container_id>> | awk '{print $1}'

# 3/ Kill the process id
sudo kill -9 <<process_id>>


comments powered by Disqus