If you need for any reason to kill all docker containers and remove all docker-related data, use following procedure:
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker network rm $(docker network ls -q)
docker volume rm $(docker volume ls -q)
docker system prune --all --volumes --force
What this will do?
- Stop and delete all docker containers
- Remove all docker images
- Remove all docker interfaces
- Remove all docker volumes
- Clear-up Docker system leftovers…
This will not uninstall Docker and/or docker compose, but now your system will be clean like after initial docker installation.