docker compose config fails with YAML anchor syntax error in docker-compose-template.yaml #21317

Closed
opened 2026-02-21 20:11:57 -05:00 by yindo · 2 comments
Owner

Originally created by @blacksheepaul on GitHub (Dec 27, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

main branch(2025-12-27, c393d7a2d)

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

  1. Clone the dify repository (main branch in a clean state) at c393d7a2dc, which is committed on 2025-12-27.
  2. Navigate to the docker directory:
    cd docker
  3. Run the docker compose config command:
    docker compose -f docker-compose-template.yaml config > docker-compose.yaml

✔️ Expected Behavior

The docker compose config command should successfully generate a valid docker-compose.yaml file without any errors.

Actual Behavior

The command fails with the following error:
yaml: map merge requires map or sequence of maps as the value

This prevents the generation of the composed configuration file, leaving the entire docker-compose.yaml empty, breaking the CICD pipeline.

Originally created by @blacksheepaul on GitHub (Dec 27, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version main branch(2025-12-27, c393d7a2d) ### Cloud or Self Hosted Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce 1. Clone the dify repository (main branch in a clean state) at c393d7a2dc28875e9dad8daec9ddb6b1a055d966, which is committed on 2025-12-27. 2. Navigate to the docker directory: cd docker 3. Run the docker compose config command: docker compose -f docker-compose-template.yaml config > docker-compose.yaml ### ✔️ Expected Behavior The docker compose config command should successfully generate a valid docker-compose.yaml file without any errors. ### ❌ Actual Behavior The command fails with the following error: yaml: map merge requires map or sequence of maps as the value This prevents the generation of the composed configuration file, leaving the entire docker-compose.yaml empty, breaking the CICD pipeline.
yindo added the 🐞 bug label 2026-02-21 20:11:57 -05:00
yindo closed this issue 2026-02-21 20:11:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 27, 2025):

Hi @blacksheepaul! I'm Dosu and I’m helping the dify team.

The error happens because the YAML anchor shared-api-worker-env in docker-compose-template.yaml is either empty or not defined as a map, but it's being merged into the environment section of several services using the YAML merge key (<<: *shared-api-worker-env). For the merge to work, the anchor must be a map of environment variables. You can fix this by defining x-shared-env: &shared-api-worker-env as a map, for example:

x-shared-env: &shared-api-worker-env
  ENV_VAR_1: value1
  ENV_VAR_2: value2

Then, when you use <<: *shared-api-worker-env under environment:, Docker Compose will correctly merge the variables. If you don't want any shared variables, you can define it as an empty map:

x-shared-env: &shared-api-worker-env {}

This resolves the YAML map merge error and allows docker compose config to generate the composed file as expected. More details on the anchor definition and merge usage are visible in the template and error context here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 27, 2025): <!-- Greeting --> Hi @blacksheepaul! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The error happens because the YAML anchor `shared-api-worker-env` in docker-compose-template.yaml is either empty or not defined as a map, but it's being merged into the `environment` section of several services using the YAML merge key (`<<: *shared-api-worker-env`). For the merge to work, the anchor must be a map of environment variables. You can fix this by defining `x-shared-env: &shared-api-worker-env` as a map, for example: ```yaml x-shared-env: &shared-api-worker-env ENV_VAR_1: value1 ENV_VAR_2: value2 ``` Then, when you use `<<: *shared-api-worker-env` under `environment:`, Docker Compose will correctly merge the variables. If you don't want any shared variables, you can define it as an empty map: ```yaml x-shared-env: &shared-api-worker-env {} ``` This resolves the YAML map merge error and allows `docker compose config` to generate the composed file as expected. More details on the anchor definition and merge usage are visible in the template and error context [here](https://github.com/langgenius/dify/blob/c393d7a2dc28875e9dad8daec9ddb6b1a055d966/docker/docker-compose-template.yaml#L1-L28). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cf89b9c1-dc76-4285-b346-57184b7f5b72?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20error%20happens%20because%20the%20YAML%20anchor%20%60shared-api-worker-env%60%20in%20docker-compose-template.yaml%20is%20either%20empty%20or%20not%20defined%20as%20a%20map%2C%20but%20it%27s%20being%20merged%20into%20the%20%60environment%60%20section%20of%20several%20services%20using%20the%20YAML%20merge%20key%20%28%60%3C%3C%3A%20%2Ashared-api-worker-env%60%29.%20For%20the%20merge%20to%20work%2C%20the%20anchor%20must%20be%20a%20map%20of%20environment%20variables.%20You%20can%20fix%20this%20by%20defining%20%60x-shared-env%3A%20%26shared-api-worker-env%60%20as%20a%20map%2C%20for%20example%3A%0A%0A%60%60%60yaml%0Ax-shared-env%3A%20%26shared-api-worker-env%0A%20%20ENV_VAR_1%3A%20value1%0A%20%20ENV_VAR_2%3A%20value2%0A%60%60%60%0A%0AThen%2C%20when%20you%20use%20%60%3C%3C%3A%20%2Ashared-api-worker-env%60%20under%20%60environment%3A%60%2C%20Docker%20Compose%20will%20correctly%20merge%20the%20variables.%20If%20you%20don%27t%20want%20any%20shared%20variables%2C%20you%20can%20define%20it%20as%20an%20empty%20map%3A%0A%0A%60%60%60yaml%0Ax-shared-env%3A%20%26shared-api-worker-env%20%7B%7D%0A%60%60%60%0A%0AThis%20resolves%20the%20YAML%20map%20merge%20error%20and%20allows%20%60docker%20compose%20config%60%20to%20generate%20the%20composed%20file%20as%20expected.%20More%20details%20on%20the%20anchor%20definition%20and%20merge%20usage%20are%20visible%20in%20the%20template%20and%20error%20context%20%5Bhere%5D%28https%3A//github.com/langgenius/dify/blob/c393d7a2dc28875e9dad8daec9ddb6b1a055d966/docker/docker-compose-template.yaml%23L1-L28%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30247)
Author
Owner

@kurokobo commented on GitHub (Jan 5, 2026):

First of all, docker-compose-template.yaml is a template file for generate_docker_compose, and it’s not designed to be specified directly (with the -f option) when running the docker compose command.
I don't think this issue needs to be resolved.

@kurokobo commented on GitHub (Jan 5, 2026): First of all, `docker-compose-template.yaml` is a template file for `generate_docker_compose`, and it’s not designed to be specified directly (with the `-f` option) when running the `docker compose` command. I don't think this issue needs to be resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21317