Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ssavva05/82e829c05c666065c46da9365ccbdaea to your computer and use it in GitHub Desktop.
Save ssavva05/82e829c05c666065c46da9365ccbdaea to your computer and use it in GitHub Desktop.
How to install OpenVPN with Docker on Raspberry Pi

First of all, we are going to store all the data in a Docker shared volume, called openvpn_data.

To initialise the OpenVPN configuration and CA:

$ docker run -v openvpn_data:/etc/openvpn --rm evolvedm/openvpn-rpi ovpn_genconfig -u udp://your-vpn.address.com
$ docker run -v openvpn_data:/etc/openvpn --rm -it evolvedm/openvpn-rpi ovpn_initpki

To start daemon (and auto-restart it):

$ docker run -v openvpn_data:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN -e --restart=always --name openvpn_server evolvedm/openvpn-rpi

And to create new profiles:

$ docker run -v openvpn_data:/etc/openvpn --rm -it evolvedm/openvpn-rpi easyrsa build-client-full **CLIENTNAME**
$ docker run -v openvpn_data:/etc/openvpn --rm evolvedm/openvpn-rpi ovpn_getclient **CLIENTNAME** > **CLIENTNAME**.ovpn

Then you can download your .ovpn file and start using your OpenVPN!! (if the port is correctly exposed)

About security

I'm not a real fan of giving your data security to other's containers, so if you want to compile your own image, you can use this repo:

https://github.com/evolvedm/docker-openvpn-rpi/blob/dc6159c0738a67802444a3a16ecfe6cb4e508280/Dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment