github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/system_prune.md (about) 1 # system prune 2 3 <!---MARKER_GEN_START--> 4 Remove unused data 5 6 ### Options 7 8 | Name | Type | Default | Description | 9 |:----------------------|:---------|:--------|:---------------------------------------------------| 10 | `-a`, `--all` | | | Remove all unused images not just dangling ones | 11 | [`--filter`](#filter) | `filter` | | Provide filter values (e.g. `label=<key>=<value>`) | 12 | `-f`, `--force` | | | Do not prompt for confirmation | 13 | `--volumes` | | | Prune anonymous volumes | 14 15 16 <!---MARKER_GEN_END--> 17 18 ## Description 19 20 Remove all unused containers, networks, images (both dangling and unused), 21 and optionally, volumes. 22 23 ## Examples 24 25 ```console 26 $ docker system prune 27 28 WARNING! This will remove: 29 - all stopped containers 30 - all networks not used by at least one container 31 - all dangling images 32 - unused build cache 33 Are you sure you want to continue? [y/N] y 34 35 Deleted Containers: 36 f44f9b81948b3919590d5f79a680d8378f1139b41952e219830a33027c80c867 37 792776e68ac9d75bce4092bc1b5cc17b779bc926ab04f4185aec9bf1c0d4641f 38 39 Deleted Networks: 40 network1 41 network2 42 43 Deleted Images: 44 untagged: hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f 45 deleted: sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57 46 deleted: sha256:45761469c965421a92a69cc50e92c01e0cfa94fe026cdd1233445ea00e96289a 47 48 Total reclaimed space: 1.84kB 49 ``` 50 51 By default, volumes aren't removed to prevent important data from being 52 deleted if there is currently no container using the volume. Use the `--volumes` 53 flag when running the command to prune anonymous volumes as well: 54 55 ```console 56 $ docker system prune -a --volumes 57 58 WARNING! This will remove: 59 - all stopped containers 60 - all networks not used by at least one container 61 - all anonymous volumes not used by at least one container 62 - all images without at least one container associated to them 63 - all build cache 64 Are you sure you want to continue? [y/N] y 65 66 Deleted Containers: 67 0998aa37185a1a7036b0e12cf1ac1b6442dcfa30a5c9650a42ed5010046f195b 68 73958bfb884fa81fa4cc6baf61055667e940ea2357b4036acbbe25a60f442a4d 69 70 Deleted Networks: 71 my-network-a 72 my-network-b 73 74 Deleted Volumes: 75 named-vol 76 77 Deleted Images: 78 untagged: my-curl:latest 79 deleted: sha256:7d88582121f2a29031d92017754d62a0d1a215c97e8f0106c586546e7404447d 80 deleted: sha256:dd14a93d83593d4024152f85d7c63f76aaa4e73e228377ba1d130ef5149f4d8b 81 untagged: alpine:3.3 82 deleted: sha256:695f3d04125db3266d4ab7bbb3c6b23aa4293923e762aa2562c54f49a28f009f 83 untagged: alpine:latest 84 deleted: sha256:ee4603260daafe1a8c2f3b78fd760922918ab2441cbb2853ed5c439e59c52f96 85 deleted: sha256:9007f5987db353ec398a223bc5a135c5a9601798ba20a1abba537ea2f8ac765f 86 deleted: sha256:71fa90c8f04769c9721459d5aa0936db640b92c8c91c9b589b54abd412d120ab 87 deleted: sha256:bb1c3357b3c30ece26e6604aea7d2ec0ace4166ff34c3616701279c22444c0f3 88 untagged: my-jq:latest 89 deleted: sha256:6e66d724542af9bc4c4abf4a909791d7260b6d0110d8e220708b09e4ee1322e1 90 deleted: sha256:07b3fa89d4b17009eb3988dfc592c7d30ab3ba52d2007832dffcf6d40e3eda7f 91 deleted: sha256:3a88a5c81eb5c283e72db2dbc6d65cbfd8e80b6c89bb6e714cfaaa0eed99c548 92 93 Total reclaimed space: 13.5 MB 94 ``` 95 96 ### <a name="filter"></a> Filtering (--filter) 97 98 The filtering flag (`--filter`) format is of "key=value". If there is more 99 than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) 100 101 The currently supported filters are: 102 103 * until (`<timestamp>`) - only remove containers, images, and networks created before given timestamp 104 * 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. 105 106 The `until` filter can be Unix timestamps, date formatted 107 timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed 108 relative to the daemon machine’s time. Supported formats for date 109 formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`, 110 `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local 111 timezone on the daemon will be used if you do not provide either a `Z` or a 112 `+-00:00` timezone offset at the end of the timestamp. When providing Unix 113 timestamps enter seconds[.nanoseconds], where seconds is the number of seconds 114 that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap 115 seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a 116 fraction of a second no more than nine digits long. 117 118 The `label` filter accepts two formats. One is the `label=...` (`label=<key>` or `label=<key>=<value>`), 119 which removes containers, images, networks, and volumes with the specified labels. The other 120 format is the `label!=...` (`label!=<key>` or `label!=<key>=<value>`), which removes 121 containers, images, networks, and volumes without the specified labels. 122 123 ## Related commands 124 125 * [volume create](volume_create.md) 126 * [volume ls](volume_ls.md) 127 * [volume inspect](volume_inspect.md) 128 * [volume rm](volume_rm.md) 129 * [volume prune](volume_prune.md) 130 * [Understand Data Volumes](https://docs.docker.com/storage/volumes/) 131 * [system df](system_df.md) 132 * [container prune](container_prune.md) 133 * [image prune](image_prune.md) 134 * [network prune](network_prune.md) 135 * [system prune](system_prune.md)