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)
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.
Restart the docker service: sudo systemctl restart docker. service. Restart the Host Machine. Enter inside the container docker exec -it ContainerName /bin/bash and then Kill the container kill 1.
Note that pressing `Ctrl+C` when the terminal is attached to a container output causes the container to shut down.
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)c:\programdata\docker\containers
whose name starts with the ID from step 1net start docker
- start docker engineUnfortunately the docker service still has to be stopped and started but at least I didn't have to re-install.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With