Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] `start -p <name>` treats an optional (`required: false`) dependency as required

Aperta
#14,311 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@htoyoda18 ci sta già lavorando.

Dal 8/10/2026.

  • #14312 di @htoyoda18 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go
Ambito
cli

Direzione di ricerca

The required flag is dropped when the project is rebuilt from container labels: pkg/compose/create.go writes the com.docker.compose.depends_on label without it, and projectFromName in pkg/compose/compose.go hard-codes required := true when reading it back. Compare with getProjectWithResources in down.go, which forces Required = false, and check whether start can use the same approach. Done when docker compose -p <name> start starts web after the optional init fails, matching the file-based behaviour; a linked pull request (#14312) already exists, so coordinate with it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

When a service has an optional dependency (depends_on.<svc>.required: false) that fails, docker compose start behaves differently depending on whether the compose file is read:

  • docker compose start (with the compose file): warns optional dependency "init" didn't complete successfully and starts web.
  • docker compose -p <name> start (no -f): fails with service "init" didn't complete successfully: exit 1, and web is not started.

Expected: -p <name> start treats the dependency as optional too, as it does when the file is read.

Steps To Reproduce
services:
  web:
    image: alpine:3.21
    command: sleep infinity
    depends_on:
      init:
        condition: service_completed_successfully
        required: false
  init:
    image: alpine:3.21
    command: sh -c "exit 1"
$ docker compose -p optdep up -d
$ docker compose -p optdep stop
$ docker compose -f compose.yaml -p optdep start   # exit 0, web running
$ docker compose -p optdep stop
$ docker compose -p optdep start
 Container optdep-init-1 Error service "init" didn't complete successfully: exit 1
service "init" didn't complete successfully: exit 1
$ echo $?
1
$ docker compose -p optdep ps -a --format '{{.Service}} {{.State}}'
init exited
web exited
Compose Version
Docker Compose version v5.6.0-24-g4e1cd3f4e (built from main at 4e1cd3f4e)
Docker Environment
Server Version: 29.1.3
Operating System: Docker Desktop
OSType/Architecture: linux/aarch64
Anything else?

With -p and no -f, the project is rebuilt from container labels (projectFromName), and required is lost on the way:

  • pkg/compose/create.go writes com.docker.compose.depends_on as service:condition:restart only. The label on web above is init:service_completed_successfully:false.
  • projectFromName in pkg/compose/compose.go reads it back with required := true hard-coded.
  • down/stop/restart already compensate for this: getProjectWithResources in down.go forces Required = false. start doesn't, so -p alone works for restart but not for start.

A possible fix: store required as a 4th field of the label and default to true when it is missing (labels written by older versions). #14081 lot 2 (#14296) moves compose start, including the projectFromName path, onto the plan engine, but it doesn't touch this label, so the bug would remain. Happy to send a PR if this direction is fine.

Lingua principale
Go
Stelle
38.4k
Fork
5.9k
Merge medio
2g 17h
PR unite (30g)
47

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di docker/compose

Tutte le issue di docker/compose

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.