2016-10-14 18:30:36 -04:00
---
title: "system prune"
description: "Remove unused data"
2016-11-03 18:48:30 -04:00
keywords: "system, prune, delete, remove"
2016-10-14 18:30:36 -04:00
---
2016-08-31 12:57:32 -04:00
# system prune
```markdown
2016-10-10 11:07:32 -04:00
Usage: docker system prune [OPTIONS]
2016-08-31 12:57:32 -04:00
2017-09-12 11:21:47 -04:00
Remove unused data
2016-08-31 12:57:32 -04:00
Options:
2016-12-07 17:02:13 -05:00
-a, --all Remove all unused images not just dangling ones
2017-09-12 11:21:47 -04:00
--filter filter Provide filter values (e.g. 'label=< key > =< value > ')
2016-12-07 17:02:13 -05:00
-f, --force Do not prompt for confirmation
--help Print usage
2017-09-12 11:21:47 -04:00
--volumes Prune volumes
2016-08-31 12:57:32 -04:00
```
2017-02-07 18:42:48 -05:00
## Description
2017-09-12 11:21:47 -04:00
Remove all unused containers, networks, images (both dangling and unreferenced),
and optionally, volumes.
2016-08-31 12:57:32 -04:00
2017-02-07 18:42:48 -05:00
## Examples
2016-08-31 12:57:32 -04:00
```bash
2017-09-12 11:21:47 -04:00
$ docker system prune
2017-02-07 18:42:48 -05:00
2016-08-31 12:57:32 -04:00
WARNING! This will remove:
2017-09-12 11:21:47 -04:00
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all build cache
2016-08-31 12:57:32 -04:00
Are you sure you want to continue? [y/N] y
2017-09-12 11:21:47 -04:00
Deleted Containers:
f44f9b81948b3919590d5f79a680d8378f1139b41952e219830a33027c80c867
792776e68ac9d75bce4092bc1b5cc17b779bc926ab04f4185aec9bf1c0d4641f
Deleted Networks:
network1
network2
Deleted Images:
untagged: hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
deleted: sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57
deleted: sha256:45761469c965421a92a69cc50e92c01e0cfa94fe026cdd1233445ea00e96289a
Total reclaimed space: 1.84kB
```
By default, volumes are not removed to prevent important data from being
deleted if there is currently no container using the volume. Use the `--volumes`
flag when running the command to prune volumes as well:
```bash
$ docker system prune -a --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 images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
2016-10-18 02:20:12 -04:00
Deleted Containers:
0998aa37185a1a7036b0e12cf1ac1b6442dcfa30a5c9650a42ed5010046f195b
2016-08-31 12:57:32 -04:00
73958bfb884fa81fa4cc6baf61055667e940ea2357b4036acbbe25a60f442a4d
2017-09-12 11:21:47 -04:00
Deleted Networks:
my-network-a
my-network-b
2016-08-31 12:57:32 -04:00
Deleted Volumes:
named-vol
Deleted Images:
untagged: my-curl:latest
deleted: sha256:7d88582121f2a29031d92017754d62a0d1a215c97e8f0106c586546e7404447d
deleted: sha256:dd14a93d83593d4024152f85d7c63f76aaa4e73e228377ba1d130ef5149f4d8b
untagged: alpine:3.3
deleted: sha256:695f3d04125db3266d4ab7bbb3c6b23aa4293923e762aa2562c54f49a28f009f
untagged: alpine:latest
deleted: sha256:ee4603260daafe1a8c2f3b78fd760922918ab2441cbb2853ed5c439e59c52f96
deleted: sha256:9007f5987db353ec398a223bc5a135c5a9601798ba20a1abba537ea2f8ac765f
deleted: sha256:71fa90c8f04769c9721459d5aa0936db640b92c8c91c9b589b54abd412d120ab
deleted: sha256:bb1c3357b3c30ece26e6604aea7d2ec0ace4166ff34c3616701279c22444c0f3
untagged: my-jq:latest
deleted: sha256:6e66d724542af9bc4c4abf4a909791d7260b6d0110d8e220708b09e4ee1322e1
deleted: sha256:07b3fa89d4b17009eb3988dfc592c7d30ab3ba52d2007832dffcf6d40e3eda7f
deleted: sha256:3a88a5c81eb5c283e72db2dbc6d65cbfd8e80b6c89bb6e714cfaaa0eed99c548
Total reclaimed space: 13.5 MB
```
2017-09-12 11:21:47 -04:00
> **Note**: The `--volumes` option was added in Docker 17.06.1. Older versions
> of Docker prune volumes by default, along with other Docker objects. On older
> versions, run `docker container prune`, `docker network prune`, and
> `docker image prune` separately to remove unused containers, networks, and
> images, without removing volumes.
2017-02-07 18:42:48 -05:00
### Filtering
2016-12-07 17:02:13 -05:00
2017-10-20 13:51:17 -04:00
The filtering flag (`--filter`) format is of "key=value". If there is more
2016-12-07 17:02:13 -05:00
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"` )
The currently supported filters are:
* until (`< timestamp > `) - only remove containers, images, and networks created before given timestamp
2017-04-10 14:08:40 -04:00
* label (`label=< key > `, `label=<key>=<value>` , `label!=<key>` , or `label!=<key>=<value>` ) - only remove containers, images, networks, and volumes with (or without, in case `label!=...` is used) the specified labels.
2016-12-07 17:02:13 -05:00
The `until` filter can be Unix timestamps, date formatted
timestamps, or Go duration strings (e.g. `10m` , `1h30m` ) computed
relative to the daemon machine’ s time. Supported formats for date
formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05` ,
`2006-01-02T15:04:05.999999999` , `2006-01-02Z07:00` , and `2006-01-02` . The local
timezone on the daemon will be used if you do not provide either a `Z` or a
`+-00:00` timezone offset at the end of the timestamp. When providing Unix
timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
fraction of a second no more than nine digits long.
2017-04-10 14:08:40 -04:00
The `label` filter accepts two formats. One is the `label=...` (`label=< key > ` or `label=<key>=<value>` ),
which removes containers, images, networks, and volumes with the specified labels. The other
format is the `label!=...` (`label!=< key > ` or `label!=<key>=<value>` ), which removes
containers, images, networks, and volumes without the specified labels.
2017-02-07 18:42:48 -05:00
## Related commands
2016-08-31 12:57:32 -04:00
* [volume create ](volume_create.md )
* [volume ls ](volume_ls.md )
* [volume inspect ](volume_inspect.md )
* [volume rm ](volume_rm.md )
2016-10-18 06:50:11 -04:00
* [volume prune ](volume_prune.md )
2016-10-17 12:04:52 -04:00
* [Understand Data Volumes ](https://docs.docker.com/engine/tutorials/dockervolumes/ )
2016-08-31 12:57:32 -04:00
* [system df ](system_df.md )
* [container prune ](container_prune.md )
2016-10-10 11:26:05 -04:00
* [image prune ](image_prune.md )
2016-10-18 00:36:52 -04:00
* [network prune ](network_prune.md )
2016-08-31 12:57:32 -04:00
* [system prune ](system_prune.md )