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?

  • lemmyvore@feddit.nl
    link
    fedilink
    English
    arrow-up
    4
    ·
    16 hours ago

    You can’t use dependencies cross-stack.

    If you know the IP that the gluetun interface is supposed to have you tell the BT client to use that interface as output interface. Usually BT clients have this option, other apps might not.

    Another thing you can do is wrap the client in a script that waits for the interface to be up (respond to ping) before it moves one. Something like (in sh):

    while ! ping -c 1 -q -W 1 "$IP" &>/dev/null ; do
        echo "Waiting for ${IP} to come up..."
        sleep 5
    done
    # run BT client here
    

    Alternatively if the gluetun interface itself doesn’t respond to ping, you can ping something else (like 1.1.1.1) through the interface, and use the -I ${IP} option for ping to bind to it for output.