docker / compose

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

[BUG] COMPOSE_PROFILES not read from env file if `--env-file` flag is passed #11955

Open mohan-13 opened 6 days ago

mohan-13 commented 6 days ago

Description

Current Behaviour: When --env-file flag is passed from the command line and COMPOSE_PROFILES is specified in the env file, the value is not used for the profiles configuration.

Expected Behaviour: The COMPOSE_PROFILES value specified in the env file should be set as the profile configuration and respective containers should be started.

Steps To Reproduce

Configuration Files: docker-compose.yml

services:
  nginx1:
    image: nginx
    profiles:
      - nginx1
  nginx2:
    image: nginx
    profiles:
      - nginx2

.env.dev

COMPOSE_PROFILES=nginx1,nginx2

When we run docker compose --env-file .env.dev up -d a message no service selected is thrown.

But both the services nginx1,nginx2 should be started.

Compose Version

docker compose version:
Docker Compose version v2.27.1-desktop.1

docker-compose version:
Docker Compose version v2.27.1-desktop.1

Docker Environment

Server:
 Server Version: 26.1.4
 Storage Driver: overlay2 
 Kernel Version: 6.6.31-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 Name: docker-desktop

Client:
 Version:    26.1.4
 Context:    desktop-linux
 Debug Mode: false

Anything else?

No response

ShadowLNC commented 3 days ago

Duplicate #11856