Best practice for connecting to a vpn though docker [closed]
Another option would be to ask Jess Frazelle (jfrazelle
), who is in the habit of containerizing everything.
Sure enough, she has a jfrazelle/dockerfiles/openvpn
project which exposes it directly to the host:
vpn: build: . volumes: - .:/etc/openvpn net: host devices: - /dev/net/tun:/dev/net/tun cap_add: - NET_ADMIN
It uses a TUN (not TAP) interface.
Probably the easiest solution would be to configure any containers that need the vpn to use the network namespace of the vpn container. That is, your docker-compose.yml would include something like:
vpn: image: myvpn_imageapp1: image: app1_image net: container:vpn
With this configuration, the vpn
container and the app1
container see the same network evironment.