Skip to content

run checkConsistency after profiles were applied#606

Merged
ndeloof merged 1 commit intocompose-spec:mainfrom
ndeloof:checkConsistency
Mar 21, 2024
Merged

run checkConsistency after profiles were applied#606
ndeloof merged 1 commit intocompose-spec:mainfrom
ndeloof:checkConsistency

Conversation

@ndeloof
Copy link
Copy Markdown
Collaborator

@ndeloof ndeloof commented Mar 20, 2024

run checkConsistency after profiles were applied.
If we don't, some services may refer to dependencies disabled by profile

As a side effect, this also allows to (ab)use profiles to define same resource twice with distinct configuration:
close docker/compose#11619.

@wrimle
Copy link
Copy Markdown

wrimle commented Mar 20, 2024

Just to clarify the use case in #11616 (which was marked as a duplicate of this). I am using the profiles to have one profile without and another with redundancy (of solr and zookeeper). This means that a lot of configuration and container dependencies change. Still it is useful to have a stable name of the "lead" container across profiles, as it makes it possible to do "docker cp" and "docker exec" from scripts that are not profile aware. I am using environment variables for a lot, but it does not work for all use cases.

@luciangabor
Copy link
Copy Markdown

There is also a question of how far do you want to go with such checks ...

$ docker compose -f - up --scale service=2 <<-'EOF'
services:
  service:
    image: nginx
    container_name: service
EOF
WARNING: The "service" service is using the custom container name "service". Docker requires each container to have a unique name. Remove the custom name to scale the service.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof merged commit 3c676fd into compose-spec:main Mar 21, 2024
@ndeloof ndeloof deleted the checkConsistency branch December 1, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Docker compose yaml containers using different profiles but same container_name fails

3 participants