Add general topic about pruning objects#4089
Conversation
|
|
||
| The `docker image prune` command allows you to clean up unused images. By | ||
| default, `docker image prune` only cleans up _dangling_ images. A dangling | ||
| image is one that is not tagged and is not referenced by any running container. |
There was a problem hiding this comment.
remove running here, stopped containers also count
| When you stop a container, it is not automatically removed unless you started | ||
| it with the `--rm` flag. To see all containers on the Docker host, including | ||
| stopped containers, use `docker ps -a`. You may be surprised how many containers | ||
| exist, especially on a development system! A stopped container's read-only and |
There was a problem hiding this comment.
the read-only layers are not removed (the read-only layers are what makes up an "image")
|
|
||
| By default, all unused volumes are removed. You can limit the scope using | ||
| the `--filter` flag. For instance, the following command only removes | ||
| volumes older than 24 hours: |
There was a problem hiding this comment.
volumes don't (yet) support the until filter, you could use an example using labels, e.g.
prune all volumes that don't have the "keep" label;
docker volume prune --filter label!=keep
There was a problem hiding this comment.
(the label filter is supported by all object types)
| objects older than 24 hours: | ||
|
|
||
| ```bash | ||
| $ docker system prune --filter "until=24h" |
There was a problem hiding this comment.
Use the label filter here; the "until" filter cannot be used with volumes, so will produce an error; docker-archive/docker-ce#154
There was a problem hiding this comment.
There's also discussion about the validity of filters on "system prune"; docker/cli#311 (comment) (perhaps we should remove the filtering section here altogether)
| @@ -0,0 +1,187 @@ | |||
| --- | |||
| description: Pruning unused objects | |||
| keywords: pruning, prune, images, volumes, containers, networks, disk, administration | |||
There was a problem hiding this comment.
We should have "garbage collection", "garbage collection" as keyword.
Perhaps even use it in the title ("Garbage collecting - pruning unused Docker objects")
londoncalling
left a comment
There was a problem hiding this comment.
@mstanleyjones approved after addressing @thaJeztah 's comments
|
Addressed feedback. |
Fixes #4000
I needed to document that volumes are not automatically pruned by
docker system pruneanymore as of 17.06.1, and I realized we don't have a general topic about pruning objects, so I wrote one. This is againstmastersince the behavior change is actually in 17.06.1 and 17.07.0.