kylemanna / docker-openvpn

🔒 OpenVPN server in a Docker container complete with an EasyRSA PKI CA
https://hub.docker.com/r/kylemanna/openvpn/
MIT License
8.68k stars 2.38k forks source link

Connecting openvpn server to multiple docker networks #602

Open rsegecin opened 3 years ago

rsegecin commented 3 years ago

After following the configuration steps on Readme I decided to start OpenVPN with a compose file and it worked great until I tried to connect with other docker networks. Does OpenVPN only allow connection with one docker network? Depending on which network I choose I lose the connection with the internet as well. Trying to debug, when I have OpenVPN configured with interfaces to other networks that can't be accessed through VPN, I'm still able to ping and curl services in other networks from inside the ovpn container.

Follows the compose file:

version: '3.5'

networks:
    api_network:
      external: true
    network:

volumes:
  ovpn-data-volume:
    external: true
  portainer_data:

services:
  portainer:
    restart: always
    image: portainer/portainer-ce
    ports:
      - "8000:8000"
      - "9000:9000"
    networks:
      network:
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

  openvpn:
    restart: always
    cap_add:
    - NET_ADMIN
    image: kylemanna/openvpn
    ports:
    - "1194:1194/udp"
    networks:
      network:
      api_network:
    volumes:
    - ovpn-data-volume:/etc/openvpn

If I leave just the network or(xor) api_network it works as if it is mutually exclusive.

erhan- commented 3 years ago

I can only do it with a single network, see https://github.com/kylemanna/docker-openvpn/issues/622