[BUG] Negative replica count in scale flags (docker compose scale / --scale) is accepted without validation
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 30/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Go
- Estrellas
- 38.9k
- Forks
- 6k
- Merge medio
- 2 d 22 h
- PR fusionados (30 d)
- 81
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de docker/compose
-
[BUG] `docker compose port` prints `:0` (exit 0) for a port the image exposes but the service does not publishPosiblemente ocupada @ndeloof la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
docker/compose#14435 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] deploy.restart_policy without condition drops the restart policyQuizá libre de nuevo @akshat-lakhera la tomó hace 25 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
docker/compose#14383 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] up: an optional (required: false) service_healthy dependent is not started when a required dependent shares the failing waitPosiblemente ocupada @ndeloof la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
docker/compose#14507 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] pre_stop hooks are skipped when up or scale stops a containerPosiblemente ocupada @htoyoda18 la tomó hace 11 días. Abiertokind/bug status/approved
Dificultad 4/5 3-5 días Aptitud para principiantes 53/100
Los mantenedores suelen responder en 1 día
Todos los issues de docker/compose
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
fluxcd/notification-controller#1441 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OneBusAway/maglev#2145 ·
Los mantenedores suelen responder en 2 días
-
priority/medium status/ready type/chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
discobox-ai/discobox#1357 ·
Los mantenedores suelen responder en 1 día
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itPosiblemente ocupada @fzn0x la tomó hoy. Abiertobug priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
edit_file diff rendering panics on invalid UTF-8 textPosiblemente ocupada @TDnorthgarden la tomó hoy. Abiertoarea/tui
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
docker/docker-agent#4955 ·
Los mantenedores suelen responder en 1 día