Hi,
I have a use-case where I'm starting to develop a docker-compose.yml configuration of 20+ services. I'd like to start grouping similar services together so that I can run docker-compose up
on a select group, instead of listing the individual services. What are your thoughts about supporting a groups
attribute that supports an array of tags, like:
myservice:
container_name: myservice
build: services/myservice
groups:
- core
- web
mydatabase:
container_name: mydatabase
build: services/mydatabase
groups:
- core
- web
something_else:
container_name: somethingelse
build: services/something_else
groups:
- misc
To start myservice
and mydatabase
, I could run docker-compose up --groups=core
, docker-compose up --groups=core,web
, etc.
Thanks!
I personally think this is better handled by splitting the service into separate files (which is already supported by Compose). Then to run a group of services you can run just one of the files.
However this wouldn't support multi-group membership (like the above example).
# Run just the core group
docker-compose -f core.yml up -d
# Run misc
docker-compose -f core.yml -f misc.yaml up -d
I agree with slnovak, I want to keep my unified docker-compose file to let docker-compose resolve startup dependencies. Dependencies are a good feature but I cannot use them with different docker-compose projects (files). Groups could resolve this scenario maybe...
A temporary workaround would be to define a minimalistic container which immediately stops after starting (e.g. tianon/true
) but has dependencies on other containers and thereby forces Docker Composer to start them before.
Example:
myservice:
container_name: myservice
build: services/myservice
groups:
- core
- web
mydatabase:
container_name: mydatabase
build: services/mydatabase
groups:
- core
- web
something_else:
container_name: somethingelse
build: services/something_else
groups:
- misc
core:
image: tianon/true
restart: "no"
depends_on:
- myservice
- mydatabase
Then run:
$ docker-compose up -d core
The request makes totally sense to me too.
The start of such composed services group works even without however, how to stop the entire list of containers all at once?
docker-compose -f core.yml up -d
Ok. But doing a stop wont work at all - at least not to me.
docker-compose -f core.yml stop
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it had not recent activity during the stale period.
Most helpful comment
A temporary workaround would be to define a minimalistic container which immediately stops after starting (e.g.
tianon/true
) but has dependencies on other containers and thereby forces Docker Composer to start them before.Example:
Then run: