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

depends_on external service/container #6166

Closed
m3talstorm opened this issue Sep 5, 2018 · 4 comments
Closed

depends_on external service/container #6166

m3talstorm opened this issue Sep 5, 2018 · 4 comments
Labels

Comments

@m3talstorm
Copy link

Versions:

  • Docker: 18.06.0-ce
  • Docker-compose: 1.22.0
  • Docker-compose.yml: 2.4

Overview:

Currently I have a single docker-compose.yml file which contains 2 dozen services, out of these servies there are some which I do not want to stop when I docker-compose down. They can be logically grouped into "configuration/discovery stack", "logging stack", "persistence stack", "application stack", etc (note: the general use of 'stack' not a specific docker stack).

For example, the configuration/discovery stack is a cluster of 3 etcd services and a registrator. Multiple other stacks depend on this, and this should be rarely taken down (docker-compose down), were as the stacks that depend on it could be taken down at any time.

If all these stacks are put into a single docker-compose.yml file they are all started and stopped together (unless you docker stop a specific containers - painful)

If these stacks are seperated into individual files then I can docker-compose -f mutliple files at the same time, but the docker-compose down will bring them all down as well


Problem:

Most of the services use depends_on to specify start order (+ healthchecks), when depends_on is validated it only checks to see if the current service_config (and any merged configs ... multiple -f) contains the service name, it does not check to see if these containers are already running outside of compose (like external_links does). This means that in the below example, if elasticsearch has a depends_on on registrator it will error with ERROR: Service 'elasticsearch' depends on service 'registrator' which is undefined.

extends also doesn't seem to solve the problem because its just config copying/merging.

Is there a way of achieving this?


Goal setup:

docker-compose.etcd.yml

services:
- registrator
- etcd1
- etcd2
- etcd3

networks:
- etcd: (driver:bridge)

docker-compose.elk.yml

services:
- kibana
- logstash
- elasticsearch

networks:
- elk: (driver:bridge)
- etcd: (external:true)

docker-compose.app.yml

services:
- service1
- service2
- service3
- etc

networks:
- elk: (external:true)
- etcd: (external:true)

General operation:

docker-compose -f docker-compose.etcd.yml up
docker-compose -f docker-compose.elk.yml up
docker-compose -f docker-compose.app.yml up
...
docker-compose -f docker-compose.app.yml down

@stale
Copy link

stale bot commented Oct 9, 2019

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.

@stale stale bot added the stale label Oct 9, 2019
@stale
Copy link

stale bot commented Oct 16, 2019

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Oct 16, 2019
@dolanor
Copy link

dolanor commented Dec 23, 2020

I'm having the same kind of thought.
I guess one way to achieve this would be to have some kind of ambassador proxies for each external services. But it is subpar, it adds latency and complexifies the compose files.
I'm surprised there is not more following of this use case.

@PackElend
Copy link

same issue here (and discussed in #2075)
The answer in https://stackoverflow.com/a/67149225/4442591 might help.
Still searching for full example...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants