pre_start hooks: per_replica: true is accepted by the schema but always rejected at runtime
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
The issue is in pkg/compose/pre_start.go where runPreStart validates hooks. The compose-spec model is in types/hooks.go. To implement, examine the reconciliation-plan work in #14221, specifically planPreStartHookRunners. Need to modify the planning to create one runner per hook per replica, adjust naming/labeling (e.g., com.docker.compose.hook-index), resolve VolumesFrom per replica, and update execution in execPreStartHook. Start by reading the existing validation and the skipped planning logic.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What this issue is about
pre_start hooks support a per_replica attribute in the compose-spec model (types.PreStartHook.PerReplica, compose-go's types/hooks.go): "runs the hook once per service replica instead of once per service." docker/compose's engine, however, does not implement it: runPreStart (pkg/compose/pre_start.go) validates every declared hook up front and rejects the whole service if any hook sets per_replica: true:
for i, hook := range service.PreStart {
if hook.PerReplica {
return fmt.Errorf("service %q pre_start[%d]: per_replica is not yet supported; remove per_replica or set it to false", service.Name, i)
}
}
So today, per_replica: true is accepted by the loader/schema but always a hard error at runtime — there is no path to actually use it.
Illustration
services:
app:
image: alpine
command: sleep infinity
deploy:
replicas: 3
pre_start:
- image: alpine
command: ["sh", "-c", "echo initializing replica"]
per_replica: true
$ docker compose up -d
service "app" pre_start[0]: per_replica is not yet supported; remove per_replica or set it to false
The only way to get this compose file to run at all today is to drop per_replica: true, at which point the hook runs once for the whole service (against the lowest-numbered replica only, per the current one-hook-one-runner model) instead of once per replica — a different, sometimes unacceptable behavior for hooks that need to prepare per-replica state (e.g. per-replica config files, per-replica volume initialization).
Suggested scope for an implementation
The reconciliation-plan work in #14221 (pre_start hook runners as first-class plan resources) planned one CreateHookContainer operation per declared hook, targeted at a single resolved replica. Supporting per_replica: true would mean planning one runner per hook × per replica instead, with:
- a deterministic name/label scheme distinguishing replicas (e.g. extending the existing
com.docker.compose.hook-indexlabel with a replica index, or a dedicated label), VolumesFromresolved against that replica rather than the lowest-numbered one,- the corresponding execution-phase change in
runPreStart/execPreStartHookto run and account for one runner per replica.
This issue only tracks the feature gap; the reconciliation-plan groundwork from #14221 already discussed and worked around it (see its planPreStartHookRunners, which explicitly skips planning entirely for a service with any per_replica: true hook, to avoid orphaning runners that could never execute).
- Lenguaje dominante
- Go
- Estrellas
- 38.4k
- Forks
- 5.9k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 73
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
-
Epic: Move service selection into the backend API instead of pre-filtering the project in the CLIAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
Los mantenedores suelen responder en 1 día
-
Watch: exec modePosiblemente ocupada @glours la tomó hace 3 días. Abiertokind/feature
docker/compose#14326 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Restore build concurrency limit now that bake supports itPosiblemente ocupada @maxproske la tomó hoy. Abiertokind/feature
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
[BUG] `start -p <name>` treats an optional (`required: false`) dependency as requiredQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 22/100
Los mantenedores suelen responder en 1 día
-
[BUG] `mode` attribute in `configs` works but raises an unsupported warningPosiblemente ocupada @ndeloof la tomó hace 8 días. Abiertokind/bug
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
docker/compose#14288 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de docker/compose
Issues similares
-
area/import kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
kind/documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
kubernetes-sigs/dra-driver-nvidia-gpu#1569 ·
Los mantenedores suelen responder en 1 día
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
openclaw/openclaw-enterprise#2571 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
All resource links brokenAbierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día