[BUG] `start -p <name>` treats an optional (`required: false`) dependency as required
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #14312 của @htoyoda18 — đã đóng, không merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 22/100
Hướng nghiên cứu
The required flag is dropped when the project is rebuilt from container labels: pkg/compose/create.go writes the com.docker.compose.depends_on label without it, and projectFromName in pkg/compose/compose.go hard-codes required := true when reading it back. Compare with getProjectWithResources in down.go, which forces Required = false, and check whether start can use the same approach. Done when docker compose -p <name> start starts web after the optional init fails, matching the file-based behaviour; a linked pull request (#14312) already exists, so coordinate with it before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When a service has an optional dependency (depends_on.<svc>.required: false) that fails, docker compose start behaves differently depending on whether the compose file is read:
docker compose start(with the compose file): warnsoptional dependency "init" didn't complete successfullyand startsweb.docker compose -p <name> start(no-f): fails withservice "init" didn't complete successfully: exit 1, andwebis not started.
Expected: -p <name> start treats the dependency as optional too, as it does when the file is read.
Steps To Reproduce
services:
web:
image: alpine:3.21
command: sleep infinity
depends_on:
init:
condition: service_completed_successfully
required: false
init:
image: alpine:3.21
command: sh -c "exit 1"
$ docker compose -p optdep up -d
$ docker compose -p optdep stop
$ docker compose -f compose.yaml -p optdep start # exit 0, web running
$ docker compose -p optdep stop
$ docker compose -p optdep start
Container optdep-init-1 Error service "init" didn't complete successfully: exit 1
service "init" didn't complete successfully: exit 1
$ echo $?
1
$ docker compose -p optdep ps -a --format '{{.Service}} {{.State}}'
init exited
web exited
Compose Version
Docker Compose version v5.6.0-24-g4e1cd3f4e (built from main at 4e1cd3f4e)
Docker Environment
Server Version: 29.1.3
Operating System: Docker Desktop
OSType/Architecture: linux/aarch64
Anything else?
With -p and no -f, the project is rebuilt from container labels (projectFromName), and required is lost on the way:
pkg/compose/create.gowritescom.docker.compose.depends_onasservice:condition:restartonly. The label onwebabove isinit:service_completed_successfully:false.projectFromNameinpkg/compose/compose.goreads it back withrequired := truehard-coded.down/stop/restartalready compensate for this:getProjectWithResourcesindown.goforcesRequired = false.startdoesn't, so-palone works forrestartbut not forstart.
A possible fix: store required as a 4th field of the label and default to true when it is missing (labels written by older versions). #14081 lot 2 (#14296) moves compose start, including the projectFromName path, onto the plan engine, but it doesn't touch this label, so the bug would remain. Happy to send a PR if this direction is fine.
- Ngôn ngữ chính
- Go
- Star
- 38.4k
- Fork
- 5.9k
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 60
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của docker/compose
-
Watch: exec modeCó thể đã có người làm @glours đã nhận 1 ngày trước. Đang mởkind/feature
docker/compose#14326 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/feature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] `mode` attribute in `configs` works but raises an unsupported warningCó thể đã có người làm @ndeloof đã nhận 5 ngày trước. Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
docker/compose#14288 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Warns about uid/gid, but with inline configs they do workCó thể đã có người làm @ndeloof đã nhận 5 ngày trước. Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
docker/compose#14283 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của docker/compose
Issue tương tự
-
Action Required: Fix Renovate ConfigurationCó thể đã có người làm @thompson-tomo đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
open-telemetry/opentelemetry-collector#16170 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
automation awf compiler specifications
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
state:triage-needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
puppe1990/amarra-cais#342 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
replay: a run cancelled during environment setup is logged as an ERROR (Instrument drops the cancellation)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày