compose-spec / compose-go

Reference library for parsing and loading Compose YAML files
https://compose-spec.io
Apache License 2.0
355 stars 112 forks source link

run checkConsistency after profiles were applied #606

Closed ndeloof closed 7 months ago

ndeloof commented 7 months ago

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 https://github.com/docker/compose/issues/11619.

wrimle commented 7 months ago

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 commented 7 months ago

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.