1. Home
  2. Docker
  3. Docker Tutorials
  4. Docker – Prune Objects

Docker – Prune Objects

Prune Objects in Docker

Generally, Docker doesn’t remove unused objects (images, containers, volumes, and networks) from the system unless you explicitly ask Docker to do so. It provides an option to Prune the unused objects from the system.

Syntax:

docker [object] prune [options]

Where object can be image, coantiner, volume, or a network.

Prune All Unused Objects

This will remove all unused objects like images, containers, volumes, and networks from the system.

$ docker system prune

The –all option will remove all unused images

$ docker system prune --all

The filtering flag (-f or –filter) format is “key=value”. Like until () will remove containers, images, and networks created before given timestamp

$ docker system prune --filter "until=24h"

Prune Images

This will remove all unused images from system.

$ docker image prune

Prune Containers:

This will remove all unused volumes from system.

$ docker container  prune 

–filter Provide filter values (e.g. ‘label=’)
–force , -f false Do not prompt for confirmation

Prune Volume:

This will remove all unused volumes from system.

$ docker volume prune 

–filter Provide filter values (e.g. ‘label=’)
–force , -f false Do not prompt for confirmation

Prune Network:

This will remove all unused docker networks from system.

$ docker network prune 

–filter Provide filter values (e.g. ‘label=’)
–force , -f false Do not prompt for confirmation