TIL - Removing dead docker containers
Encountered this issue that there were some dead containers:
docker ps -af status=dead
Removing them with docker rm did nothing:
docker rm -f <container-id>
Did nothing, the containers will pop up once again when running docker ps.
They had to be removed from the file system with:
rm -rf /var/lib/docker/containers/<container-id>
And then restart the docker daemon with:
systemctl restart docker
Some notes:
- Dont know at what point the containers die.
- The dead containers once belonged to a docker service.
- As part of their lifecicle, these services are stoped, restarted and removed.
- Dead containers did not belong to any existing service.
- No processes seemed to use the dead containers.