I use gluetun, my arr stack and bittorrent client in a single docker-compose. I use the syntax
depends_on:
gluetun:
condition: service_healthy
in the stack to make sure that the bittorrent client doesn’t try to connect too early. All that works great.
I also use that same VPN connection for other containers too (not in the same docker-compose stack). I do that by simply using network_mode: "container:gluetun" in the second yaml file. But I’d like to use the same depends_on syntax. But it errors out because gluetun is undefined in the second stack.
So my question is, how do I make sure the containers in docker compose stack 2 start after docker compose stack 1 (the one with gluetun) is healthy?
Removed by mod
Darn. I had the same question as OP but have been working around it by combining everything into the same stack. It’s just a bit of a pain to edit the stack every time I want to test something or retire a service.
Good work-arounds though! Maybe I should move to a script-based startup… Only trouble is all my containers are tagged with
restart: unless-stoppedso Docker restarts all of it at once on reboot which would mess up the order. Hmm.
Try network_mode: service:gluetun
It uses the container name instead of the Id number
One option nobody mentioned: Compose has a top-level
include:(Compose v2.20+). In stack 2 addinclude: - ../stack1/docker-compose.ymland gluetun becomes part of the same project, so
depends_on: gluetun: condition: service_healthyworks again. The catch is thatdocker compose up/downin stack 2 now manages gluetun too, so it’s best if stack 1 is only gluetun and everything else lives in its own files.deleted by creator


