Skip to content

[BUG] docker compose up foo does not bring up other services within the same profile #12244

@zwimer

Description

@zwimer

Description

I am moving this bug docker/docs#21258 from the docs repo to the compose repo. According to https://docs.docker.com/compose/how-tos/profiles/

When a service with assigned profiles is explicitly targeted on the command line its profiles are started automatically so you don't need to start them manually. This can be used for one-off services and debugging tools. As an example consider the following configuration:

This promise is not honored by docker compose currently

Steps To Reproduce

Given docker-compose.yml file:

services:

  foo:
    container_name: foo_c
    profiles: [ test ]
    image: alpine
    command: [ "sleep", "10000" ]

  bar:
    container_name: bar_c
    profiles: [ test ]
    image: alpine
    command: [ "sleep", "10000" ]

Running docker compose up -d foo gives:

$ docker compose up -d foo
[+] Running 2/2
 ✔ Network foo_default  Created                                                                                      0.3s
 ✔ Container foo_c      Started

As you can see, bar is not started, as it would be via docker compose --profile test up -d:

$ docker compose --profile test up -d
[+] Running 3/3
 ✔ Network foo_default  Created                                                                                      0.3s
 ✔ Container bar_c      Started                                                                                      0.6s
 ✔ Container foo_c      Started

Compose Version

Docker Compose version v2.29.7

Docker Environment

Client: Docker Engine - Community
Version: 27.3.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.17.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.7
Path: /usr/libexec/docker/cli-plugins/docker-compose

Server:
Containers: 52
Running: 51
Paused: 0
Stopped: 1
Images: 65
Server Version: 27.3.1
Storage Driver: overlay2
Backing Filesystem: btrfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
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: runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
runc version: v1.1.14-0-g2c9f560
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.11.3-200.fc40.x86_64
Operating System: Fedora Linux 40 (Workstation Edition)
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 62.64GiB
Name: Redacted
ID: ed88d9cb-bb99-42bd-9131-566f815d7a6c
Docker Root Dir: /var/lib/docker
Debug Mode: false
Username: redacted
Experimental: false
Insecure Registries:
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