Unable to stop, kill or remove Docker container
I've got a container running for 5 weeks now which I can neither stop nor kill nor remove. docker ps
shows this (both containers cannot be removed actually):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
431a850b384f f99983306232 "cmd /c 'start /B C:…" 5 weeks ago Up 5 weeks 0.0.0.0:80->80/tcp dockercompose18429431017078490850_xxx_1
e31f0b74a8cb 50eef858d93d "cmd /c 'start /B C:…" 6 weeks ago Up 6 weeks 0.0.0.0:80->80/tcp dockercompose15856640072218908353_xxx_1
docker stop e31
and docker kill e31
just hung up and do nothing. docker rm e31
shows error:
Error response from daemon: removal of container e31 is already in progress
If I run docker inspect e31
I see the container is running, it's not dead:
"Id": "e31f0b74a8cb8225d5104f8de7e1c583ed1852133ad2870015017b09d3df8dfa",
"Created": "2019-05-08T06:57:24.3143863Z",
...
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1324,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-05-08T06:57:30.3396878Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
...
How to get rid of it?
System info:
Server Version: 19.03.0-rc2
Operating System: Windows 10 Pro Version 1903 (OS Build 18362.175)
I have also encountered this a few times. What I did to stop the 'hung' container was -
-
docker ps
to display container ID -
net 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.
That may sound too radical but I've just reinstalled Docker. The redundant containers have gone. Finally.
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