[BUG] Negative replica count in scale flags (docker compose scale / --scale) is accepted without validation
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Go
- Sterne
- 38.9k
- Forks
- 6k
- Ø Merge
- 2 T. 22 Std.
- Gemergte PRs (30 T.)
- 81
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus docker/compose
-
[BUG] `docker compose port` prints `:0` (exit 0) for a port the image exposes but the service does not publishEvtl. vergeben @ndeloof hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
docker/compose#14435 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] deploy.restart_policy without condition drops the restart policyEvtl. wieder frei @akshat-lakhera hat das vor 25 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
docker/compose#14383 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] up: an optional (required: false) service_healthy dependent is not started when a required dependent shares the failing waitEvtl. vergeben @ndeloof hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 58/100
docker/compose#14507 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] pre_stop hooks are skipped when up or scale stops a containerEvtl. vergeben @htoyoda18 hat das vor 11 Tagen übernommen. Offenkind/bug status/approved
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 53/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
IBM-Cloud/terraform-provider-ibm#7115 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
fluxcd/notification-controller#1441 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
volcengine/volcengine-go-sdk#163 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
OneBusAway/maglev#2145 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
priority/medium status/ready type/chore
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
discobox-ai/discobox#1357 ·
Maintainer antworten meist innerhalb von 1 Tag