-
Clear images cache
You can use the command docker image prune
to delete all dangling and intermediate images:
First, let's list existing images:
By default intermediate images are hidden, you need to use the option -a (--all) to list all images:
Delete dangling images:
Check that dangling and intermediate images were deleted:
-
Clear stopped containers
You can use the command docker container prune
to delete all stopped containers:
Let's start a container:
Check the container (note that the container exited because it didn't run in foreground):
Delete stopped containers:
-
Clear unused networks
You can use the command docker network prune
to delete all unused networks:
Create a test network:
Delete unused networks:
-
Clear unused local volumes
You can use the command docker volume prune
to delete all unused local volumes:
Create a test volume:
Delete unused volumes:
-
Clear all Docker unused objects (images, containers, networks, local volumes)
You can also use the command docker system prune
to delete all unused objects.
This will delete images cache, stopped containers, unused networks, and unused local volumes:
Delete unused objects: