After enough times of getting tired having to go into Portainer to edit/recreate my qBittorrent container to use the gluetun network service, I decided to try and create a docker compose to upload as a stack.
Unfortunately, when adding a depends_on for gluetun in the qBittorrent service, I cannot get qBt to wait long enough for gluetun to connect to a server and be considered healthy. I was wondering if anyone else has run into an issue like this and been able to create a working healthcheck for gluetun that will allow the VPN to connect and then signal to qBt that it is clear to start.
TIA

The trick is that gluetun ships its own built-in healthcheck, and the “VPN not ready yet” problem usually comes from either (a) overriding it or (b) qBittorrent trying to bind before the tun device is up. A working pattern:
services: gluetun: image: qmcgaw/gluetun cap_add: - NET_ADMIN devices: - /dev/net/tun:/dev/net/tun environment: - VPN_SERVICE_PROVIDER=yourprovider healthcheck: test: ["CMD", "sh", "-c", "wget -qO- https://ipinfo.io/ip"] interval: 30s timeout: 10s retries: 5 start_period: 60s qbittorrent: image: linuxserver/qbittorrent network_mode: "service:gluetun" depends_on: gluetun: condition: service_healthy restart: unless-stoppedNotes:
start_period: 60s(or higher) is the key setting people miss — docker doesn’t count failures againstretriesduring the start period, so gluetun gets its full handshake window (some providers take 30-60s) before qBt is allowed to start.network_mode: "service:gluetun"qBt has no network of its own, so those checks will always fail.firewall) handles the drop-protection case.Reference: gluetun wiki, Healthcheck page.