Clarify that --rm works with detached containers

Add clarification in the 'Remove anonymous volumes' section that the
--rm option works with both foreground and detached (-d) containers.
Anonymous volumes are cleaned up when the container exits, regardless
of how it was started.

Fixes #19717

Assisted-By: docker-agent
This commit is contained in:
David Karlsson
2026-03-20 10:11:12 +01:00
parent 55e175d1a7
commit 94c2be0e20

View File

@@ -784,6 +784,9 @@ To automatically remove anonymous volumes, use the `--rm` option. For example,
this command creates an anonymous `/foo` volume. When you remove the container,
the Docker Engine removes the `/foo` volume but not the `awesome` volume.
The `--rm` option works with both foreground and detached (`-d`) containers.
The anonymous volumes are cleaned up when the container exits.
```console
$ docker run --rm -v /foo -v awesome:/bar busybox top
```