Skip to content
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

Feature Request: Add depends_on support for external Compose files #3951

Closed
pcgeek86 opened this issue Sep 15, 2016 · 15 comments
Closed

Feature Request: Add depends_on support for external Compose files #3951

pcgeek86 opened this issue Sep 15, 2016 · 15 comments

Comments

@pcgeek86
Copy link

For more complex applications, with many components, it would be useful to be able to make a Docker Compose service depends_on an external docker-compose.yml file.

Is this something that can be added?

Cheers,
Trevor Sullivan
Docker Captain
Microsoft MVP: Cloud & Data Center Management
https://trevorsullivan.net
https://twitter.com/pcgeek86

@pcgeek86 pcgeek86 changed the title Feature Request: Add dependency for a Feature Request: Add depends_on support for external Compose files Sep 15, 2016
@shin-
Copy link

shin- commented Sep 20, 2016

Hi!

Do you mind giving an example of a case where you feel that would be useful? I have a feeling it's already possible to do what you need with the current Compose feature set, but I'd like to understand your setup better first.

@pcgeek86
Copy link
Author

@shin- Sure, we are adding a separate application logging stack, that's made up of several containers. This logging stack is based on ElasticSearch, Logstash, and Kibana (ELK). We'd like to leave this in a separate Compose file, so we can deploy and validate it separately from our microservices. What is your recommended approach for this scenario?

@shin-
Copy link

shin- commented Sep 22, 2016

You can have multiple Compose files, one called docker-compose.yml (default) for your microservices, and docker-compose-logging.yml with your logging stack. You can then start your entire stack with docker-compose -f docker-compose.yml -f docker-compose-logging.yml, with dependencies being resolved as if they were part of the same file. There's more docs on the -f option on this page

@pcgeek86
Copy link
Author

@shin- Thanks -- we will give that a shot!

@olalonde
Copy link

olalonde commented Oct 6, 2016

@alwaysastudent
Copy link

This issue has leg. The scenario we need the external depends_on is to start the services only if a reverse-proxy service is started and be running already from another project. The reverse-proxy project will compose the shared network and be ready as soon as the backend services come up.

@jayaskren
Copy link

We would also like this. I am running an integration tests inside jenkins. The first docker-compose file is used to set up and configure the services I'm testing. The second docker-compose file is to run the actual tests. I then want the Jenkins job to pass or fail depending on the results of the test in the second docker-compose file.

@shin-
Copy link

shin- commented May 5, 2017

@jayaskren

docker-compose.yml

version: '2.1'
services:
  web:
   ...
  db:
   ...
volumes:
  ...
networks:
  ...

docker-compose-tests.yml

version: '2.1'
services:
  testrunner:
    ...

Run application: docker-compose up
Run tests: docker-compose -f docker-compose.yml -f docker-compose-tests.yml up --exit-code-from testrunner

@jayaskren
Copy link

@shin- One of my containers starts a database, the second one loads data into the database, then I have several containers that launch microservices that talk to that database. Then the last service runs my tests against those services. When I tried your suggestion, I see in the logs:
using --exit-code-from implies --abort-on-container-exit

and as I've seen before, the stack comes down once the second container finishes loading data into the database due to the abort-on-container-exit command. I really want to abort on container exit but only for my testrunner container.

@drzraf
Copy link

drzraf commented Jun 13, 2018

still an issue given that moby/moby#31101 keeps us from split a docker-compose among multiple regular files:
Can't run a database-related compose first then run/rerun a (dependent) web-app compose.

@nyurik
Copy link

nyurik commented Nov 21, 2018

I also have a similar issue: I need to start several databases, run a very long import process, and finally start a set of microservices. Ideally, I should be able to break that into 3 distinct docker-compose.yml files, and I would not want to run them in the same up command. Rather, I would

  1. docker-compose up -f databases.yml --detach
  2. docker-compose up -f importjobs.yml (without --detach to wait until all of them finish)
  3. docker-compose up -f services.yml --detach

It would be good to be able to use depends_on inside the second and third set to ensure the DB services are still running.

@nycynik
Copy link

nycynik commented May 26, 2019

You can have multiple Compose files, one called docker-compose.yml (default) for your microservices, and docker-compose-logging.yml with your logging stack. You can then start your entire stack with docker-compose -f docker-compose.yml -f docker-compose-logging.yml, with dependencies being resolved as if they were part of the same file. There's more docs on the -f option on this page

But this will require they are all in the same project as well, right?

@totopopov
Copy link

Has anyone managed to find a work around on depends_on in the case where you want one service to start after one has already completely loaded?

@123unix
Copy link

123unix commented May 10, 2020

You can have multiple Compose files, one called docker-compose.yml (default) for your microservices, and docker-compose-logging.yml with your logging stack. You can then start your entire stack with docker-compose -f docker-compose.yml -f docker-compose-logging.yml, with dependencies being resolved as if they were part of the same file. There's more docs on the -f option on this page

This is exactly what the new feature request is all about!

Indeed, how else - in the new syntax which would be developed - would you specify external dependency between docker-compose files?

@cosama
Copy link

cosama commented Oct 12, 2022

Just realized we have been using the depends_on flag wrong, by defining dependencies from different docker-compose.yml. Only a recent updates actually made this throw an error.

We have a on-system-start.yml that defines a bunch of services that are started on system boot. Then we have a bunch of services defined in another on-user-action.yml that are started on a button being pressed in a web UI. However, they require some services defined in on-system-start.yml. Right now we don't really have a compose way of checking that these services are still up and running.

Definitely would be happy about this feature as well.

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

No branches or pull requests