I am trying to create several different docker-compose apps that utilize the same express VPN connection. Ideally what I would like to do is create a docker network called vpn, create a container called expressvpn that connects to a VPN and allows any container on the vpn network to connect to the VPN. I know I can create a docker container with a container network stack by specifying --net container:expressvpn. The problem with this approach is that any port I would like accessible by my local network needs to be forwarded in the expressvpn container. I also can't seem to use this approach with docker-compose.
So my question is: is there any such way to create a VPN network? Would it be possible to do this with a network plugin?
You get anywhere with this?
If not, you can try what i do, for me it works. I also have a cron job that restarts the docker compose every 2 days, because i have had issues with the vpn reconnecting no matter what i do. restarting docker compose works just fine now.
Use docker-compose.yaml for all your containers you want to use for vpn.
Put all the ports for all containers on the expressvpn container like this.
services:
expressvpn:
ports:
- "8112:8112" #Deluge
- "6881:6881/tcp" #Deluge
- "6881:6881/udp" #Deluge
Then for each of the containers put the following. This will use the expressvpn container for internet access.
deluge:
depends_on:
- expressvpn
network_mode: "service:expressvpn"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With