Installing and configuring OpenVPN for Docker on Raspberry Pi
I followed this guide to download and install OpenVPN for Docker.
# The name of the setup container
export OVPN_SETUP="ovpn_setup"
# The name of the server container
export OVPN_SERVER="ovpn_server"
# The hostname of our server
export OVPN_HOSTNAME="vpn.domain.tld"
# create the container volume
docker run --name "$OVPN_SETUP" -v /etc/openvpn hypriot/armhf-busybox
# initialize OpenVPN container
docker run --volumes-from "$OVPN_SETUP" --rm evolvedm/openvpn-rpi ovpn_genconfig -u udp://"$OVPN_HOSTNAME"
docker run --volumes-from "$OVPN_SETUP" --rm -it evolvedm/openvpn-rpi ovpn_initpki
# start OpenVPN server process
docker run --volumes-from "$OVPN_SETUP" -d -p 1194:1194/udp --cap-add=NET_ADMIN -e --restart=always --name "$OVPN_SERVER" evolvedm/openvpn-rpi
Creating and exporting clients
To create and export clients, we can do the following:
# the name of the client
export CLIENT="your-client-name"
# generate client configuration
docker run --volumes-from "$OVPN_SETUP" --rm -it evolvedm/openvpn-rpi easyrsa build-client-full "$CLIENT" nopass
# download client configuration from docker container to local machine
docker run --volumes-from "$OVPN_SETUP" --rm evolvedm/openvpn-rpi ovpn_getclient "$CLIENT" > "$CLIENT.ovpn"