libcompose
libcompose copied to clipboard
Resolve dependencies on compose up
compose up starts all services and automatically resolves all dependencies between services in the compose file.
compose up app with docker-compose starts app and all of it's dependencies, however with libcompose this only starts app
myapp $ docker-compose up app
Creating myapp_db_1
Creating myapp_app_1
Attaching to myapp_app_1
docker compose version:
docker-compose version 1.8.0, build f3628c7
docker-py version: 1.9.0
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.2h 3 May 2016
I thought libcompose used to do this. Perhaps this is a regression.
If someone could provide some guidance for this I could submit a PR for it
I'm pretty sure I was wrong with my earlier comment. This would definitely be a cool feature to have, although I think there are use cases where someone might not want this functionality. We should have an option to enable/disable this.
@bfosberry I'm not sure which commands this would effect, but I know we'll have to modify Up at least.
Up takes in a list of services. This list would need to be transformed at the top of the command to include all of the dependencies of those services. The dependencies can be found with this function.
Still a few open questions here. Should we have the same functionality for Start? What if one of dependent services doesn't have its containers started yet?
Hmmm...yeah. So default compose behaviour is to bring up all dependent services, so it would make sense for that to be the default here, although if its a flag in a context thats not a big deal especially if it gets documented.
For docker/compose it looks like we just need to take the provided service, get a list of non duplicated services, and send that on. Most project functions take an "include_deps" flag which we should probably make sure is passed around inside project also, but thats a larger issue
For the CLI I think we should enforce this change by default and allow someone to override as needed, with the same --no-deps flag docker/compose uses atm.
To determine dependencies I think we can use this logic here: https://github.com/docker/compose/blob/acfe100686fd95d524ff102c0b5fccff0bc79d8c/compose/service.py#L519
It looks like Docker Compose only allows overriding dependencies for the run command, so we should probably match that behavior. For library use cases, we could allow overriding this for other commands with a flag here.
I think our dependency logic already matches what you've referenced. We just need to enable it fully and also bring up dependent services.