Skip to content

Breaking change in minor version: env-file variable substitution behavior changed in v2.8.0 #813

@aartoni

Description

@aartoni

A breaking change was introduced in compose-go between versions v2.7.1 and v2.8.0, specifically in commit 8da9902, altering how environment variables are resolved when using multiple env_files.

This affects Docker Compose behavior between versions 2.38.2 and 2.39.0, specifically in commit 8f91793 (i.e., when compose-go was updated to intermediate version v2.7.2-0.20250721082312-a42e7579d813), where variable substitution within the same env_file now behaves differently. The change is breaking, though possibly intentional as it complies with the compose spec, however it was not documented.

I'd suggest reverting the change for now (PR here #814), then updating the major version number as per semver and releasing again afterwards, mentioning the breaking change in the release notes. Note that this should also trigger a major version bump on docker-compose as it can (and has, in my case) break existing compose setups.

Steps to reproduce

# .local.env
TLD=local
# .env
TLD=org
URL=http://example.${TLD}
# compose.yml
services:
  testenv:
    image: alpine
    command: sh -c 'echo "URL=$URL"'

Run as follows.

$ docker compose version
Docker Compose version 2.38.2
$ docker compose --env-file .local.env --env-file .env up --build
URL=http://example.local

$ docker compose version
Docker Compose version 2.39.0
$ docker compose --env-file .local.env --env-file .env up --build
URL=http://example.org

Notice that the output changes based on the version of Docker Compose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions