Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#14,383 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@akshat-lakhera is already working on this.

Since Oct 24, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, go
Domain
devops

Research direction

Start in pkg/compose/create.go at getRestartPolicy, then run the focused unit tests covering that function. Confirm that deploy.restart_policy without a condition uses the spec default any and does not discard restart: always; the invalid on-failure retry count behavior should also be covered if included in the change. Done means these cases have regression tests and the focused test suite passes.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Go
Stars
38.4k
Forks
5.9k
Avg merge
1d 19h
Merged PRs (30d)
66

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/compose

All issues in docker/compose

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.