Clean up any resources from the Docker
Purge or clear all the resources like networks, images, volumes, and containers that are not linked with any container
# docker system prune
Remove stopped containers and all unused images by using -a
# docker system prune -a
Remove specific images:
--List the images
# docker images -a
--Remove specific images
#docker rmi <imageid>
-- Note: if you want to remove all images
# docker rmi $(docker images -a -q)
Remove specific containers:
--list all container running or existed
# docker ps -a
--Remove specific container
# docker rm <containername or containerid>
--Note: IF you want to remove all containers then first stop and remove:
# docker stop $(docker ps -a -q)
# docker rm $(docker ps -a -q)
--Remove only existed status container:
--list them
# docker ps -a -f status=exited
--remove them
# docker rm $(docker ps -a -f status=exited -q)
Remove specific volumes:
--list the volumes
# docker volume ls
--remove the specific volume
# docker volume rm name
--remove all the unused volumes:
# docker volume prune