Volumes can be used by one or more containers, and take up space on the Docker
host. Volumes are never removed automatically, because to do so could destroy
data.
```console
$ docker volume prune
WARNING! This will remove all volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
```
By default, you are prompted to continue. To bypass the prompt, use the `-f` or
`--force` flag.
By default, all unused volumes are removed. You can limit the scope using
the `--filter` flag. For instance, the following command only removes
volumes which aren't labelled with the `keep` label:
```console
$ docker volume prune --filter "label!=keep"
```
Other filtering expressions are available. See the
[`docker volume prune` reference](/reference/cli/docker/volume/prune.md)
for more examples.
## Prune networks
Docker networks don't take up much disk space, but they do create `iptables`
rules, bridge network devices, and routing table entries. To clean these things
up, you can use `docker network prune` to clean up networks which aren't used
by any containers.
```console
$ docker network prune
WARNING! This will remove all networks not used by at least one container.
Are you sure you want to continue? [y/N] y
```
By default, you're prompted to continue. To bypass the prompt, use the `-f` or
`--force` flag.
By default, all unused networks are removed. You can limit the scope using
the `--filter` flag. For instance, the following command only removes
networks older than 24 hours:
```console
$ docker network prune --filter "until=24h"
```
Other filtering expressions are available. See the
[`docker network prune` reference](/reference/cli/docker/network/prune.md)
for more examples.
## Prune everything
The `docker system prune` command is a shortcut that prunes images, containers,
and networks. Volumes aren't pruned by default, and you must specify the
`--volumes` flag for `docker system prune` to prune volumes.
```console
$ docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- unused build cache
Are you sure you want to continue? [y/N] y
```
To also prune volumes, add the `--volumes` flag:
```console
$ docker system prune --volumes
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all volumes not used by at least one container
- all dangling images
- all build cache
Are you sure you want to continue? [y/N] y
```
By default, you're prompted to continue. To bypass the prompt, use the `-f` or
`--force` flag.
By default, all unused containers, networks, and images are removed. You can
limit the scope using the `--filter` flag. For instance, the following command
removes items older than 24 hours:
```console
$ docker system prune --filter "until=24h"
```
Other filtering expressions are available. See the
[`docker system prune` reference](/reference/cli/docker/system/prune.md)
for more examples.