docker system prune
To remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:
docker system prune -a
Use the docker images
command with the -a
flag to locate the ID of the images you want to remove.
# list images
docker images -a
# remove
docker rmi <Image ID or name>
# list dangling images
docker images -f dangling=true
# remove
docker images purge
docker rmi $(docker images -a -q)
# list
docker ps -a
# remove
docker rm <contaner ID or name>
# list
docker ps -a -f status=exited
# remove
docker rm $(docker ps -a -f status=exited -q)
# remove all containers
docker rm $(docker ps -a -q)
# list
docker volume ls
# remove
docker volume rm <volume name>
# list
docker volume ls -f dangling=true
# remove
docker volume prune