buildMountOptions warns "should not define `bind` option" for named volumes carrying only an SELinux relabel flag, which compose itself consumes
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 62/100
研究方向
從 buildMountOptions() 開始,當 mount 的類型為 volume 且 Bind 非 nil 時,此處會觸發警告。檢查 buildContainerVolumes() 和 toBindString() 如何為具名卷使用 v.Bind.SELinux,使警告只略過 Bind 僅設定 SELinux 的情況。對於 propagation 和 create_host_path 等其他 Bind 欄位,保留警告。完成標準是:帶有 z/Z 的具名卷掛載不產生警告,而帶有其他 Bind 欄位的卷掛載仍會警告,並由 buildMountOptions 的測試涵蓋。
由索引模型根據 Issue 內容生成。
描述
Description
A named-volume mount written with the documented short syntax vol:/path:z
canonicalises to type: volume + bind: {selinux: z}; bind.selinux is the
compose model's only slot for a relabel flag (volume: {selinux: z} is a schema
error, so there is no long-syntax alternative). buildMountOptions() then warns
unconditionally on volume.Type != VolumeTypeBind && volume.Bind != nil,
so every such mount emits a warning on every container create.
The warning is a false positive here, because compose itself consumes the
option it is warning about: two functions later buildContainerVolumes()
routes plain named-volume mounts through the legacy HostConfig.Binds string
API via toBindString(), which appends v.Bind.SELinux (the modern Mounts
API cannot express relabels). Support for bind.selinux on named volumes was
added deliberately in compose-spec/compose-go#213 (fixing #9072, where the
flags were silently dropped). So the configuration is correct, compose honours
it, and the user is told it is wrong.
Steps to reproduce
services:
probe:
image: busybox:latest
command: ["true"]
volumes:
- probevol:/data:z,rw
volumes:
probevol:
docker compose up prints, once per z/Z-flagged named-volume mount per create:
time="..." level=warning msg="mount of type `volume` should not define `bind` option"
docker inspect confirms the flag was honoured:
Binds: ["proj_probevol:/data:rw,z"].
Expected
No warning when the bind: struct on a type: volume mount sets only
selinux, since that field is both the sole supported spelling and one compose
acts on. A bind: struct setting other fields (propagation,
create_host_path) on a volume mount should keep warning.
Impact
On SELinux-enforcing hosts the flags are load-bearing, so the warning cannot be
avoided by dropping them, and --log-level error suppresses all warnings rather
than this one. Deployment tooling ends up filtering the line out of compose's
stderr. It also breaks machine-readable output for downstream consumers:
ansible-collections/community.docker#846 is the same line failing an event
parser.
Versions
Reproduced on Compose v5.1.3 / Engine 29.4.1 (2026-07-19) and Compose v5.5.0 /
Engine 29.7.2 (2026-09-06). buildMountOptions() on main is unchanged.
- 主要語言
- Go
- 星號
- 38.9k
- 分支
- 6k
- 平均合併
- 2 天 22 小時
- 30 天內合併 PR
- 81
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
docker/compose 的其他 Issue
-
[BUG] `docker compose port` prints `:0` (exit 0) for a port the image exposes but the service does not publish可能已有人在做 @ndeloof 於 1 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[BUG] deploy.restart_policy without condition drops the restart policy可能重新可做 @akshat-lakhera 於 25 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
docker/compose#14383 · 3 則留言 ·
維護者通常 1 天內回覆
-
[BUG] up: an optional (required: false) service_healthy dependent is not started when a required dependent shares the failing wait可能已有人在做 @ndeloof 於 2 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 58/100
docker/compose#14507 · 2 則留言 ·
維護者通常 1 天內回覆
-
[BUG] Negative replica count in scale flags (docker compose scale / --scale) is accepted without validation可能已有人在做 @arsalanyavari 於 8 天前認領。 未關閉kind/bug status/approved
難度 2/5 1-3 小時 新手友好度 30/100
維護者通常 1 天內回覆
-
[BUG] pre_stop hooks are skipped when up or scale stops a container可能已有人在做 @htoyoda18 於 11 天前認領。 未關閉kind/bug status/approved
難度 4/5 3-5 天 新手友好度 53/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
IBM-Cloud/terraform-provider-ibm#7115 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 86/100
fluxcd/notification-controller#1441 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 66/100
volcengine/volcengine-go-sdk#163 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
OneBusAway/maglev#2145 ·
維護者通常 2 天內回覆
-
priority/medium status/ready type/chore
難度 2/5 1-3 小時 新手友好度 84/100
discobox-ai/discobox#1357 ·
維護者通常 1 天內回覆