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

[BUG] deploy.restart_policy without condition drops the restart policy

Aperta Adatta ai principianti
#14,383 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@akshat-lakhera ci sta già lavorando.

Dal 24/10/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, go
Ambito
devops

Direzione di ricerca

Inizia da pkg/compose/create.go in getRestartPolicy, poi esegui i test unitari mirati che coprono quella funzione. Conferma che deploy.restart_policy senza una condizione usi il valore predefinito della spec any e non scarti restart: always; se incluso nella modifica, deve essere coperto anche il comportamento del conteggio dei tentativi non valido per on-failure. Fatto significa che questi casi hanno test di regressione e che la suite di test mirata viene superata.

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

Descrizione

Description

When a service sets deploy.restart_policy but leaves out condition, compose sends an empty restart policy name to the engine and drops the service-level restart value too.

In pkg/compose/create.go, getRestartPolicy first works out the policy from the restart field, and then if deploy.restart_policy is set it replaces the whole thing with mapRestartPolicyCondition(policy.Condition). compose-go doesn't fill in a default for condition, so it stays empty and the default case in mapRestartPolicyCondition passes the empty string through. The Compose spec says condition defaults to any, but the engine accepts an empty name without an error, so the container is created and just never restarts.

Steps To Reproduce
services:
  app:
    image: alpine
    command: sh -c "exit 1"
    restart: always
    deploy:
      restart_policy:
        max_attempts: 3

Calling getRestartPolicy with this service gives Name "" and MaximumRetryCount 3. The same happens with only delay: 5s under restart_policy.

Expected: condition defaults to any like the spec says, so the policy is always (and at least restart: always shouldn't be silently dropped).

Actual: the restart policy name is empty and the container doesn't restart.

I checked this at the function level with a unit test, not with a full docker compose up.

Anything else?

In the same function, restart: on-failure:abc silently becomes a retry count of 0 because the Atoi error is ignored, while docker run rejects that value. It could be fixed in the same PR.

Current main. If this sounds right, I would like to work on this.

Lingua principale
Go
Stelle
38.5k
Fork
5.9k
Merge medio
2g 19h
PR unite (30g)
77

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.