[BUG] Negative replica count in scale flags (docker compose scale / --scale) is accepted without validation
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 30/100
调研方向
The report identifies the scale and up --scale CLI paths but names no source files or tests. Start by tracing how each command parses and validates replica counts, then find the corresponding tests. Done means both commands reject negative counts while accepting zero and positive counts; an open linked pull request is already addressing this issue.
由索引模型根据 Issue 内容生成。
描述
Description
According to the Compose Specification, scale must be a non-negative integer (>= 0). The Compose file loader already enforces this and rejects negative scale: values in compose.yaml.
Additionally, the CLI properly validates non-numeric inputs — for instance, docker compose scale web=abc immediately returns:
invalid scale specifier: can't parse replica value as int: web=abc
However, when passing a negative replica count through the CLI flags, such as docker compose scale web=-1 or docker compose up --scale web=-1, the value is accepted without any validation error. The service is then assigned a negative replica count, which leads to unexpected behavior during convergence and container lifecycle handling.
The CLI should validate that the replica count is non-negative, consistent with the Compose Specification and with how the compose file loader treats negative scales.
Steps To Reproduce
- Create a minimal
compose.yaml:services: web: image: alpine - Attempt to scale the service with a negative replica count:
Or:docker compose scale web=-1docker compose up --dry-run --scale web=-1
Observed Result
-
docker compose scale web=-1:[+] scale 1/1 ✔ Network a_default Created 0.0s service "web" has no container to startThe negative value
-1is accepted without any validation error. -
docker compose up --dry-run --scale web=-1:end of 'compose up' output, interactive run is not supported in dry-run modeThe command finishes without warning or error regarding the negative replica count.
Compose Version
$ docker compose version
Docker Compose version v5.5.0
Docker Environment
Docker version 29.9.3, build 5457199aa5
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.17.2
Path: /path/to/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v5.5.0
Path: /path/to/.docker/cli-plugins/docker-compose
Anything else?
No response
- 主要语言
- 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 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
docker/compose#14435 · 2 条评论 ·
维护者通常 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] 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 小时 新手友好度 86/100
fluxcd/notification-controller#1441 ·
维护者通常 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 天内回复
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for it可能已有人在做 @fzn0x 今天认领。 未关闭bug priority: low
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
edit_file diff rendering panics on invalid UTF-8 text可能已有人在做 @TDnorthgarden 今天认领。 未关闭area/tui
难度 2/5 1-3 小时 新手友好度 85/100
docker/docker-agent#4955 ·
维护者通常 1 天内回复