docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.71k stars 5.19k forks source link

[BUG] Loading COMPOSE_FILE from .env-file stopped working #11922

Closed david-jointech closed 3 months ago

david-jointech commented 3 months ago

Description

After updating to compose 2.27.1 loading the COMPOSE_FILE from a .env-file doesn't work anymore as expected. The variable is set, but the additional docker-compose files aren't loaded.

Steps To Reproduce

  1. I set up the following compose-files:

docker-compose.yaml

services:
  test:
    image: bash
    volumes:
      - ./test:/test

docker-compose.network.yaml

services:
  test:
    networks:
      - internal
networks:
  internal:

.env

 COMPOSE_FILE=docker-compose.yaml:docker-compose.network.yaml
  1. Then I run the following command:

    docker compose --env-file .env config

    Which gives me this output:

    name: compose-test
    services:
    test:
    image: bash
    networks:
      default: null
    volumes:
      - type: bind
        source: <pwd>/compose-test/test
        target: /test
        bind:
          create_host_path: true
    networks:
    default:
    name: compose-test_default

    As can be seen, the network-compose-file is completly ignored in this scenario.

    When I run docker compose --file docker-compose.yaml --file docker-compose.network.yaml config instead, I get the expected output:

    name: compose-test
    services:
    test:
    image: bash
    networks:
      internal: null
    volumes:
      - type: bind
        source: <pwd>/compose-test/test
        target: /test
        bind:
          create_host_path: true
    networks:
    internal:
    name: compose-test_internal

This also applies to other docker compose commands (e.g. up).

Compose Version

Docker Compose version 2.27.1

Docker Environment

No response

Anything else?

No response

ndeloof commented 3 months ago

Already fixed by https://github.com/docker/compose/pull/11889