From 94c2be0e2059ac82fdd3886a5b041b99cc7877c1 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Fri, 20 Mar 2026 10:11:12 +0100 Subject: [PATCH] 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 --- content/manuals/engine/storage/volumes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/content/manuals/engine/storage/volumes.md b/content/manuals/engine/storage/volumes.md index bc0eef21b4..f2ad43de43 100644 --- a/content/manuals/engine/storage/volumes.md +++ b/content/manuals/engine/storage/volumes.md @@ -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 ```