Skip to content

Commit bd48039

Browse files
committed
docs: fix and relocate anonymous-volumes documentation
Anonymous volumes get a bare UUID, not the anon-{uuid} naming command-reference.md claimed, so its own grep example matched nothing. Move the fixed explanation into volumes.md alongside the rest of the volumes docs, and trim command-reference.md to a pointer. Signed-off-by: Eric Ernst <eric_ernst@apple.com>
1 parent 855ab44 commit bd48039

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

docs/command-reference.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -911,22 +911,10 @@ container volume create --opt journal=journal --opt size=10g myvolume
911911

912912
**Anonymous Volumes**
913913

914-
Anonymous volumes are auto-created when using `-v /path` or `--mount type=volume,dst=/path` without specifying a source. They use UUID-based naming (`anon-{36-char-uuid}`):
915-
916-
```bash
917-
# Creates anonymous volume
918-
container run -v /data alpine
919-
920-
# Reuse anonymous volume by ID
921-
VOL=$(container volume list -q | grep anon)
922-
container run -v $VOL:/data alpine
923-
924-
# Manual cleanup
925-
container volume rm $VOL
926-
```
927-
928-
> [!NOTE]
929-
> Unlike Docker, anonymous volumes do NOT auto-cleanup with `--rm`. Manual deletion is required.
914+
Using `-v /path` or `--mount type=volume,dst=/path` without a source auto-creates a
915+
named volume for you, tagged with the `com.apple.container.resource.anonymous` label.
916+
See [Mounts and volumes](./volumes.md#anonymous-volumes) for how to find and clean
917+
these up.
930918

931919
### `container volume delete (rm)`
932920

docs/volumes.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ Remove every volume that isn't attached to a container:
6969
container volume prune
7070
```
7171

72-
> [!NOTE]
73-
> Unlike Docker, anonymous volumes created implicitly by a container do not
74-
> auto-cleanup when the container is removed with `--rm`. Delete them explicitly with
75-
> `container volume delete`.
76-
7772
Mount a named volume the same way you bind-mount a host directory, using the volume
7873
name as the source:
7974

@@ -87,6 +82,32 @@ Or with `--mount`:
8782
container run -it --rm --mount type=volume,source=foo,target=/mnt/foo alpine sh
8883
```
8984

85+
## Anonymous volumes
86+
87+
Using `-v /path` or `--mount type=volume,target=/path` without specifying a source
88+
auto-creates a named volume for you — an anonymous volume. It's named with a bare UUID
89+
(no prefix) and tagged with the `com.apple.container.resource.anonymous` label:
90+
91+
```bash
92+
# Creates an anonymous volume
93+
container run -v /data alpine
94+
```
95+
96+
Find it by its label (the bare UUID name has no "anon" marker to `grep` for):
97+
98+
```bash
99+
VOL=$(container volume list --format json | jq -r '.[] | select(.configuration.labels["com.apple.container.resource.anonymous"] != null) | .id')
100+
container run -v $VOL:/data alpine
101+
```
102+
103+
> [!NOTE]
104+
> Unlike Docker, anonymous volumes do **not** auto-cleanup when the container is removed
105+
> with `--rm`. Delete them explicitly:
106+
>
107+
> ```bash
108+
> container volume rm $VOL
109+
> ```
110+
90111
## Named volume mount options
91112
92113
| Option | Values | Description |

0 commit comments

Comments
 (0)