Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - Cannot remove dead container

Tags:

docker

I am unable to remove the dead container, it appears again after i restart the Docker service.

docker ps -a CONTAINER ID         STATUS           11667ef16239         Dead 

Then

docker rm -f 11667ef16239 

Then, when I ran the docker ps -a, no docker containers showing.

docker ps -a CONTAINER ID         STATUS 

However, when I restart the docker service:

service docker restart 

And run the docker ps -a again:

docker ps -a CONTAINER ID         STATUS           11667ef16239         Dead 
like image 593
Tuong Le Avatar asked Jun 12 '15 01:06

Tuong Le


People also ask

Can not remove docker container?

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.


2 Answers

Most likely, an error occurred when the daemon attempted to cleanup the container, and he is now stuck in this "zombie" state.

I'm afraid your only option here is to manually clean it up:

$ sudo rm -rf /var/lib/docker/<storage_driver>/11667ef16239.../ 

Where <storage_driver> is the name of your driver (aufs, overlay, btrfs, or devicemapper).

like image 76
icecrime Avatar answered Sep 30 '22 18:09

icecrime


You can also remove dead containers with this command

docker rm $(docker ps --all -q -f status=dead) 

But, I'm really not sure why & how the dead containers are created. This error seems related https://github.com/typesafehub/mesos-spark-integration-tests/issues/34 whenever i get dead containers

[Update] With Docker 1.13 update, we can easily remove both unwanted containers, dangling images

$ docker system df #will show used space, similar to the unix tool df $ docker system prune # will remove all unused data. 
like image 37
sk8terboi87 ツ Avatar answered Sep 30 '22 18:09

sk8terboi87 ツ