[BUG] deploy.restart_policy without condition drops the restart policy
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
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
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from docker/compose
-
[BUG] down -v removes a named volume owned by another projectPossibly taken @htoyoda18 claimed this 2 days ago. Openkind/bug
Difficulty 3/5 1-2 days Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
[BUG] A start failure in one service aborts the start of unrelated services (unreleased regression)Openkind/bug
Difficulty 4/5 3-5 days Newbie friendliness 57/100
docker/compose#14372 · 1 comment ·
Maintainers usually reply within 1 day
-
kind/feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
docker/compose#14365 · 2 comments ·
Maintainers usually reply within 1 day
-
kind/feature
Difficulty 5/5 Over a week Newbie friendliness 35/100
docker/compose#14356 · 1 comment ·
Maintainers usually reply within 1 day
-
Epic: Move service selection into the backend API instead of pre-filtering the project in the CLIOpen
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
JakeChampion/lang#13132 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Azure/azure-storage-fuse#2429 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
AvengeMedia/dank-greeter#39 · 1 comment ·
-
bug: dataplane client ignores SERVER_BASEPATH, so create/delete topic miss the subpathPossibly taken @bhataprameya claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
redpanda-data/console#2693 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
dokku/dokku-datastore#367 ·
Maintainers usually reply within 1 day