We are trying to run two apps via docker-compose
. These apps are (obviously) in separate folders, each of them having their own docker-compose.yml
. On the filesystem it looks like this:
dir/app1/
-...
-docker-compose.yml
dir/app2/
-...
-docker-compose.yml
Now we need a way to compose these guys together for they have some nitty-gritty integration via http.
The issue with default docker-compose
behaviour is that if treats all relative paths with respect to folder it is being run at. So if you go to dir
from the example above and run
docker-compose up -f app1/docker-compose.yml -f app2/docker-compose.yml
you'll end up being out of luck if any of your docker-compose.yml
's uses relative paths to env files or whatever.
Here's the list of ways that actually work, but have their drawbacks:
- Run those apps separately, and use networks.
It is described in full at Communication between multiple docker-compose projects
I've tested that just now, and it works. Drawbacks:
you have to mention network in
docker-compose.yml
and push that to repository some day, rendering entire app being un-runnable without the app that publishes the network.you have to come up with some clever way for those apps to actually wait for each other
2 Use absolute paths. Well, it is just bad and does not need any elaboration.
3 Expose the ports you need on host machine and make them talk to host without knowing a thing about each other. That is too, obviously, meh.
So, the question is: how can one manage the task with just docker-compose
?