Contents

Remove Docker Images, Containers, and Volumes

Docker takes a conservative approach to cleaning up unused objects (often referred to as “garbage collection”), such as images, containers, volumes, and networks: these objects are generally not removed unless you explicitly ask Docker to do so. This can cause Docker to use extra disk space. For each type of object, Docker provides a prune command. In addition, you can use docker system prune to clean up multiple types of objects at once

Prune everything (images, containers, and networks)

docker system prune

Prune everything (images, containers, networks and volumes)

docker system prune --volumes

Prune images

To remove all images which are not used by existing containers, use the -aflag: docker image prune -a By default, you are prompted to continue. To bypass the prompt, use the -f or --force flag.

Remove image

docker rmi image_name

Prune containers

docker container prune

Remove one or more specific containers

docker rm ID_or_NAME ID_or_NAME

Prune volumes

docker volume prune

Prune single volume:

docker volume rm volume_name

Prune networks

docker network prune

Ref: docker.com