I was trying to follow a popular assistant's guide to refactor a simple Docker Compose setup for better maintainability. The suggestion seemed logical at first, but it completely broke my environment variable flow.
The prompt was basically: "How can I structure this docker-compose.yml to avoid repeating environment variables across services?"
The assistant suggested moving all common env vars to a top-level `x-environment` anchor and referencing it. But when I tried to `docker compose up`, it failed silently because the YAML merge key syntax (`<<: *anchor`) it used doesn't actually interpolate variables. My `$DB_HOST` literals were passed as strings, not the values.
The correct answer was much simpler: just use a `.env` file at the project root and reference the variables normally in the compose file. The assistant over-engineered a "clean" YAML feature that wasn't fit for the purpose.
Has anyone else run into this? It makes me double-check every "improvement" now.