clear all docker containers code example
Example 1: remove docker container
# List all containers (only IDs)
docker ps -aq
# Stop all running containers
docker stop $(docker ps -aq)
# Remove all containers
docker rm $(docker ps -aq)
# Remove all images
docker rmi $(docker images -q)
Example 2: how to clean up all docker containers
docker container list -qa | xargs docker container stop && docker container prune
Example 3: remove all containers docker
docker rm $(docker ps -aq)