Docker Command
Stop all running containers: This is important because you can't remove an image of a container that is still running.
bashCopy codesudo docker stop $(sudo docker ps -aq)Remove all containers: Once all containers are stopped, you can remove them.
bashCopy codesudo docker rm $(sudo docker ps -aq)Remove all Docker images: This will remove all images, including unused and dangling images.
bashCopy codesudo docker rmi $(sudo docker images -q)Remove all volumes: Volumes are used for persisting data of Docker containers. To remove them, use:
bashCopy codesudo docker volume rm $(sudo docker volume ls -q)Remove all dangling volumes: These are volumes that are no longer used by any containers.
bashCopy codesudo docker volume prune(Optional) Remove all networks: If you also want to remove all networks, you can use:
bashCopy codesudo docker network prune
Last updated