-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce profiles
attribute for depends_on
to define profiles dependency
#488
base: master
Are you sure you want to change the base?
Introduce profiles
attribute for depends_on
to define profiles dependency
#488
Conversation
…pendency Signed-off-by: Vigilans <vigilans@foxmail.com>
6a74960
to
148fa3e
Compare
Proposal: Recommended practice for component switchingThis proposal proposes a better way to manage a compose project of multiple components: use Environment setupSay we have following directory layout:
Where root networks:
...
secrets:
...
include:
- minio/compose.yml
- gitlab/compose.yml
- sharelatex/compose.yml And root COMPOSE_PROFILES=minio,gitlab,sharelatex # or '*' for all profiles Here:
Now, we can select one of the components through:
And manage all services the old-school way by not providing profile:
It works because root
Use
|
Quoted from docker/compose#10993 (comment):
@GethDeeo Your idea can be solved using With following config: services:
db:
profiles: [database]
web:
depends_on:
db:
condition: service_healthy
profiles: [database]
|
What this PR does / why we need it:
Before compose version
2.18.1
, starting a service depending on services in an inactivated profile will not trigger error. This behavior gets fixed in docker/compose#10602.However, the problem with this feature is that it's implicit, but not that it's of no value. In fact, before and after the fix landed many people report and request about this feature to be available.
required
keyword was added for it in #382.This PR takes the solution further, to explicitly support specifying
profiles
as dependency independs_on
entries.Behavior of
depends_on.profiles
:Example config:
db
is central db for all services,web-redis
is redis instance that only servesweb
.Here:
docker compose --profile web up
whendb
not created/started:db-init
anddb
will be created and started, thenweb-redis
andweb
is created and started.docker compose --profile web up --force-recreate
whendb
is healthy:Only
web-redis
andweb
is selected and created/started, sincedb
is already ready.docker compose --profile web down
whendb
is healthy:db
will not be selected, onlyweb-redis
andweb
is stopped and removed.docker compose --profile web restart
whendb
is healthy:db
will not be selected, onlyweb-redis
andweb
is restarted.More formal use cases of this feature will be elaborated on subsequent comments.
Which issue(s) this PR fixes:
docker/compose#10751
docker/compose#10804
#274
docker/compose#10993