You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Negative replica count in scale flags (docker compose scale / --scale) is accepted without validation #14482
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:
docker compose scale web=-1
Or:
docker 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 start
The negative value -1 is 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 mode
The command finishes without warning or error regarding the negative replica count.
Compose Version
$ docker compose version
Docker Compose version v5.5.0
Activity