Skip to content

[BUG] COMPOSE_PROFILES environment variable ignored by Compose v5.0.1 #13552

@hafzaal

Description

@hafzaal

Description

Based on the documentation here: https://docs.docker.com/compose/how-tos/profiles/, the COMPOSE_PROFILES environment variable should allow selecting profiles when running Docker Compose. The documentation gives the following usage example:
COMPOSE_PROFILES=debug docker compose up

However, in my environment the variable is not being picked up by Docker Compose. I’ve tried both exporting the variable and specifying it inline as part of the Compose command, and neither method works. The --profile flag does work as expected.

Steps To Reproduce

Environment:
Ubuntu-based WSL2 environment, with Docker/Compose running through Docker Desktop on the Windows host. The WSL Integration toggle is enabled under Resources → WSL Integration.

Docker compose file:

services:
  redis_default:
    image: redis:latest

  ubuntu_test:
    image: ubuntu:latest
    command: ["sleep", "infinity"]
    profiles:
      - ubuntu

  alpine_test:
    image: alpine:latest
    command: ["sleep", "infinity"]
    profiles:
      - alpine

Specifying variable inline:

> COMPOSE_PROFILES=ubuntu docker compose up -d
 ✔ Network docker_default  Created
 ✔ Container redis_default Created

> docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS      NAMES
b7330a5f8db4   redis:latest   "docker-entrypoint.s…"   11 seconds ago   Up 10 seconds   6379/tcp   redis_default

Only the default service is started. The profile-specific service ubuntu_test is ignored.

Exporting the variable:

> export COMPOSE_PROFILES=ubuntu

> echo $COMPOSE_PROFILES
ubuntu

> docker compose up -d
 ✔ Network docker_default  Created
 ✔ Container redis_default Created 

> docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS      NAMES
300fc148e9dd   redis:latest   "docker-entrypoint.s…"   4 seconds ago   Up 3 seconds   6379/tcp   redis_default

Again, the Compose file's profile is not applied.

Using --profile flag (working):

> docker compose --profile ubuntu up -d
 ✔ Network docker_default   Created
 ✔ Container redis_default  Created
 ✔ Container ubuntu_profile Created   

Compose Version

> docker compose version
Docker Compose version v5.0.1

Docker Environment

Client:
 Version:    29.1.3
 Context:    default
 Debug Mode: false
 Plugins:
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.17.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-ai
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.30.1-desktop.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.0.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.47
    Path:     /usr/local/lib/docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Docker Inc.)
    Version:  v0.2.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-desktop
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.31
    Path:     /usr/local/lib/docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-init
  mcp: Docker MCP Plugin (Docker Inc.)
    Version:  v0.35.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-mcp
  model: Docker Model Runner (Docker Inc.)
    Version:  v1.0.6
    Path:     /usr/local/lib/docker/cli-plugins/docker-model
  offload: Docker Offload (Docker Inc.)
    Version:  v0.5.40
    Path:     /usr/local/lib/docker/cli-plugins/docker-offload
  pass: Docker Pass Secrets Manager Plugin (beta) (Docker Inc.)
    Version:  v0.0.22
    Path:     /usr/local/lib/docker/cli-plugins/docker-pass
  sandbox: Docker Sandbox (Docker Inc.)
    Version:  v0.6.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-sandbox
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.19.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-scout

Server:
 Containers: 5
  Running: 1
  Paused: 0
  Stopped: 4
 Images: 15
 Server Version: 29.1.3
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Discovered Devices:
  cdi: docker.com/gpu=webgpu
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2 nvidia
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: dea7da592f5d1d2b7755e3a161be07f43fad8f75
 runc version: v1.3.4-0-gd6d73eb8
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.87.2-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 24
 Total Memory: 31.19GiB
 Name: docker-desktop
 ID: 90cb6567-8909-4cef-ad82-b0d3fa95706f
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///var/run/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions