Sign inSign up

kmb32123/openvpn

By kmb32123

•Updated almost 5 years ago

Run OpenVPN as a Docker service to allow other containers to route their traffic through it

Image
0

1.6K

kmb32123/openvpn repository overview

⁠Docker OpenVPN Client

Original idea borrowed from https://github.com/dperson/openvpn-client⁠

⁠Starting the VPN

  1. You should add the generated openvpn client config to a directory, you can call it client.ovpn
  2. You should add the password for the private key in the client.ovpn to client.pwd
  3. Run the following, I recommend adding --auth-nocache
docker run -d --name vpn-client \
  --cap-add=NET_ADMIN \
  --device /dev/net/tun \
  -v /path/with/vpn/configs:/vpn \
  ekristen/openvpn-client --config /vpn/client.conf --askpass /vpn/client.pwd --auth-nocache

⁠Using the VPN

⁠Confirm it is working

To test that the VPN is working as intended, you can run the following command to get the public IP address that will be used by containers using the VPN network. This command uses the library/busybox image⁠ to fetch the public IP from the ipify service⁠ and print it to STDOUT.

docker run --rm --net=container:vpn-client busybox wget -qO- api.ipify.org
⁠Route container traffic

Use --net=container:<container-id> -- routes available by the VPN client will be made available to the container.

docker run -it --rm \
  --net=container:vpn-client
  ubuntu /bin/bash
⁠Using with Compose
version: '2'
services:
  my-service:
    image: "ubuntu"
    network_mode: "service:vpn-client"

Tag summary

Content type

Image

Digest

Size

9.6 MB

Last updated

over 5 years ago

docker pull kmb32123/openvpn