Skip to content

[BUG] Explicitly building services that are not part of COMPOSE_PROFILES broken since 2.36.0 #12825

Description

@ngandrass

Description

Since compose version 2.36.0 explicitly building services that are not part of any profile listed in the COMPOSE_PROFILES env variable fails.

This might be related to #12822

Steps To Reproduce

Compose file

The following compose file is used for all tests:

services:
a:
profiles:
- onebuild:
dockerfile_inline: "FROM alpine"b:
profiles:
- twobuild:
dockerfile_inline: "FROM alpine"

Behavior with compose v2.35.1

Building the image for service b works:

➜ COMPOSE_PROFILES=one docker compose build b
Compose can now delegate builds to bake for better performance.
To do so, set COMPOSE_BAKE=true.
[+] Building 1.0s (6/6) FINISHED docker:default
=> [b internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 48B 0.0s
=> [b internal] load metadata for docker.io/library/alpine:latest 0.8s
=> [b internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [b 1/1] FROM docker.io/library/alpine:latest@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c 0.0s
=> [b] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:36b6fbfb637b6421bfc7180a63566cd14679dd4f57859c09e194550f5dca5396 0.0s
=> => naming to docker.io/library/compose-b 0.0s
=> [b] resolving provenance for metadata file 0.0s
[+] Building 1/1
✔ b Built 

Running the service b works:

➜ COMPOSE_PROFILES=one docker compose run --rm b
[+] Creating 1/1
✔ Network compose_default Created 0.1s / # 

Behavior since compose v2.36.0

Explicitly building the image for service b fails if the service profile is not part of COMPOSE_PROFILES:

➜ COMPOSE_PROFILES=one docker compose build b no such service: b

Running the service, however, works:

➜ COMPOSE_PROFILES=one docker compose run --rm b
/ # 

Compose Version

Docker Compose version 2.36.0

Docker Environment

Client:
Version: 28.1.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: 0.23.0
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.36.0
Path: /usr/lib/docker/cli-plugins/docker-compose
Server:
Containers: 45
Running: 8
Paused: 0
Stopped: 37
Images: 96
Server Version: 28.1.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: true
Native Overlay Diff: false
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 061792f0ecf3684fb30a3a0eb006799b8c6638a7.m
runc version: init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.14.6-arch1-1
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 20
Total Memory: 62.48GiB
Name: <REDACTED>
ID: <REDACTED>
Docker Root Dir: /var/lib/docker
Debug Mode: false
Username: <REDACTED>
Experimental: false
Insecure Registries:
::1/128
127.0.0.0/8
Live Restore Enabled: false

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions