Can I use a docker container to route only 1 program through a VPN?

https://lemmy.world/post/433708

Can I use a docker container to route only 1 program through a VPN? - Lemmy.world

cross-posted from: https://lemmy.world/post/426190 [https://lemmy.world/post/426190] > I am running Ubuntu Server with Plex, qBittorrent-Nox, and CyberGhost. I want to route qBittorrent through the CyberGhost VPN, but not Plex. > > I have never used Docker, but from what I gather online, it seems like the containers operate like little VM’s for compartmentalization and resource allocation. If that is correct, would I be able to put qBittorrent-Nox and CyberGhost into the same docker container to route qBittorrent-Nox through the VPN while Plex runs outside the VPN in its own snap? > > Thanks for the help!

What I do on mine is rent a cheap VPS with unlimited bandwidth, I run OpenVPN server on that VPS using Nyr's openvpn-install script and then on my local seedbox server I connect to my OpenVPN server. I have qBittorrent listening on the tun0 interface, and then on my OpenVPN server VPS I have an iptables prerouting rule to route traffic from the inbound torrent port to my local seedbox server, essentially port-forwarding over the VPN using the iptables prerouting DNAT rule.

It's a very nice setup, I'd recommend it. I might do a full write-up some time about it.