mirror of
https://github.com/moby/moby.git
synced 2026-07-13 19:12:11 +00:00
`Parser.ParseMountRaw()` labels anonymous volumes with a `AnonymousLabel` label (`com.docker.volume.anonymous`) label based on whether a volume has a name (named volume) or no name (anonymous) (see [1]). However both `VolumesService.Create()` (see [1]) and `Parser.ParseMountRaw()` (see [2], [3]) were generating a random name for anonymous volumes. The latter is called before `VolumesService.Create()` is called, resulting in such volumes not being labeled as anonymous. Generating the name was originally done in Create (fc7b904dce), but duplicated inb3b7eb2723with the introduction of the new Mounts field in HostConfig. Duplicating this effort didn't have a real effect until (`Create` would just skip generating the name), until618f26ccbcintroduced the `AnonymousLabel` in (v24.0.0, backported to v23.0.0). Parsing generally should not fill in defaults / generate names, so this patch; - Removes generating volume names from `Parser.ParseMountRaw()` - Adds a debug-log entry to `VolumesService.Create()` - Touches up some logs to use structured logs for easier correlating logs With this patch applied: docker run --rm --mount=type=volume,target=/toto hello-world DEBU[2024-10-24T22:50:36.359990376Z] creating anonymous volume volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02 DEBU[2024-10-24T22:50:36.360069209Z] probing all drivers for volume volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02 DEBU[2024-10-24T22:50:36.360341209Z] Registering new volume reference driver=local volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02 [1]:032721ff75/volume/service/service.go (L72-L83)[2]:032721ff75/volume/mounts/linux_parser.go (L330-L336)[3]:032721ff75/volume/mounts/windows_parser.go (L394-L400)Signed-off-by: Sebastiaan van Stijn <github@gone.nl>