Skip to content

[BUG] Docker compose build fails silently if profiles are included in an existing compose file #13466

@virajkulkarni14

Description

@virajkulkarni14

Description

Hello Team,

Current behavior:

  • Include profiles in an existing docker compose .yml file
  • Run docker build: docker compose -f my-docker-compose-file.yml build
  • The command possibly fails silently & returns to the prompt instantly without an error message

Expected behavior:

  • It should throw an error asking the user run with a specific profile
  • The Compose docs should also mention this behavior somewhere, probably on this page?

Thanks!

Steps To Reproduce

Given an existing docker compose YAML file like so:

services:
  my-service:
    build:
      context: .
      dockerfile: My-Dockerfile
      args:
        arg1: foo
        arg2: bar
    image: my-image
    container_name: my-container
    ports:
      - "7750:7750"

If I introduce profiles in this file:

services:
  my-service:
    profiles: ["dev", "prod"]
    build:
      context: .
      dockerfile: My-Dockerfile
      args:
        arg1: foo
        arg2: bar
    image: my-image
    container_name: my-container
    ports:
      - "7750:7750"

Running docker compose -f my-docker-compose-file.yml build does nothing but return to the prompt instantly without an error message.

Compose Version

Docker Compose version v2.40.3-desktop.1

Docker Environment

Client: Docker Engine - Community
 Version:    29.1.3
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.17.1
    Path:     /home/user/.docker/cli-plugins/docker-ai
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.30.1-desktop.1
    Path:     /home/user/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.40.3-desktop.1
    Path:     /home/user/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.45
    Path:     /home/user/.docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Docker Inc.)
    Version:  v0.2.0
    Path:     /home/user/.docker/cli-plugins/docker-desktop
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.31
    Path:     /home/user/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     /home/user/.docker/cli-plugins/docker-init
  mcp: Docker MCP Plugin (Docker Inc.)
    Version:  v0.34.0
    Path:     /home/user/.docker/cli-plugins/docker-mcp
  offload: Docker Offload (Docker Inc.)
    Version:  v0.5.33
    Path:     /home/user/.docker/cli-plugins/docker-offload
  pass: Docker Pass Secrets Manager Plugin (beta) (Docker Inc.)
    Version:  v0.0.21
    Path:     /home/user/.docker/cli-plugins/docker-pass
  sandbox: Docker Sandbox (Docker Inc.)
    Version:  v0.6.0
    Path:     /home/user/.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:     /home/user/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.18.3
    Path:     /home/user/.docker/cli-plugins/docker-scout

Server:
 Containers: 23
  Running: 5
  Paused: 0
  Stopped: 18
 Images: 35
 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
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1c4457e00facac03ce1d75f7b6777a7a851e5c41
 runc version: v1.3.4-0-gd6d73eb8
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.54-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 7.652GiB
 Name: docker-desktop
 ID: d6e28057-7109-494d-aae9-557c238890ab
 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:///home/user/.docker/desktop/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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions