Unable to stop, kill or remove Docker container
I have also encountered this a few times. What I did to stop the 'hung' container was -
docker ps
to display container IDnet stop docker
- stop docker engine (Note all containers will stop)- Delete folder in
c:\programdata\docker\containers
whose name starts with the ID from step 1 net start docker
- start docker engine
Unfortunately the docker service still has to be stopped and started but at least I didn't have to re-install.
For us it was an update that changed the docker.service
config on RHEL.
Solution
docker rm -f <container-id>
systemctl daemon-reload
systemctl restart containerd
systemctl restart docker
docker-compose up -d
The Error we were receiving
docker-compose up -d --force-recreate
Recreating 952ba6a5bbc4_my-app ... error
t: connection refused: unknown'
ERROR: for 952ba6a5bbc4_my-app Cannot start service my-app: b'dial unix \x00/run/containerd/s/086e56: connect: connection refused: unknown'
ERROR: for my-app Cannot start service my-app: b'dial unix \x00/run/containerd/s/086e56: connect: connection refused: unknown'
ERROR: Encountered errors while bringing up the project.```
For urgent cases, when even docker rm -f
is does not help, it can be solved by stopping deamon and manually removing container:
sudo systemctl stop docker
sudo rm -rf /var/lib/docker/containers/<CONTAINER_ID>
sudo systemctl start docker
That may sound too radical but I've just reinstalled Docker. The redundant containers have gone. Finally.