Remove all unused or dangling images, containers, volumes, and networks in docker
Sometimes you add a new docker container and try to get it working. After opening the webapp you will find out that you already have a user and there is some data. So what happened?
Tried once, killed and forgot
In this situation I had wiki.js already installed a year ago, but totally forgot about it. Removed the dir with the docker-compose.yml
and I had no recollection about ever using it. BUT, docker saved the containers, volumes and networks on the server. So to get a clean start you will need to not just prune the container…
docker container prune
but you also need to remove the volumes, images and networks. Do do that you can use the following command. The -a
or --all
flag removes all stopped and dangling containers
docker system prune -a
More information can be found in the official docker docs: docs.docker.com/engine/reference/commandline/system_prune