Yep, this is exactly what I do.
Comment on Route outgoing traffic of a docker bridge network through VPN
BruisedMoose@piefed.social 2 days ago
First off, take this for what it is: a guy who can follow instructions but does not understand all the inner workings of docker.
I use Gluetun and have a set of apps that I run through it. They are all in the same compose file. Each of the ports is defined in the Gluetun section and not with the individual app. Then each app’s network_mode is set to service:gluetun
This routes all the traffic for those apps through the VPN while maintaining my regular network for everything else.
theunknownmuncher@lemmy.world 2 days ago
d00phy@lemmy.world 2 days ago
This was my thought as well. Anything by that requires VPN is added to that stack and if I can bind it to the “tun” device I do - but the container requires gluten to be up.
d00phy@lemmy.world 2 days ago
So I got back to my server, and here’s what I do:
gluetun settings:
services: gluetun: *snip* ports: *snip* - 8090:8090 # port for qbittorrent *snip*
qbittorrent (in the same compose.yml):
qbittorrent: image: linuxserver/qbittorrent:latest container_name: qbittorrent environment: *snip* - WEBUI_PORT=8090 *snip* network_mode: service:gluetun # run on the vpn network depends_on: gluetun: condition: service_healthy *snip*
Also, in qbittorrent settings you can bind it to a network device. In my case it’s “tun0.” This same thing can probably be done w/ a docker network in a gluetun container and separate containers that rely on that network being up, but I haven’t looked into it. Right now, I have 2 other services that require VPN, and I’m looking at possibly 1 or 2 more. That’s pretty manageable as a single stack, I think.
xana@lemmy.zip 2 days ago
Thank you very much for your reply but this is not really what I need. Please see the edit for more context :D
BakedCatboy@lemmy.ml 2 days ago
I second this. Gluetun makes it so easy, working with docker’s internal networking is such a pain.