Skip to content

Instantly share code, notes, and snippets.

@drpauldixon
Created November 18, 2015 18:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drpauldixon/cdde5fc654c3e2aedf87 to your computer and use it in GitHub Desktop.
Save drpauldixon/cdde5fc654c3e2aedf87 to your computer and use it in GitHub Desktop.
Run OpenVPN via Docker on port 8443

Docker OpenVPN

From: https://www.digitalocean.com/community/tutorials/how-to-run-openvpn-in-a-docker-container-on-ubuntu-14-04

This will pull in the docker images that are required to run OpenVPN:

OVPN_DATA="ovpn-data"
docker run --name $OVPN_DATA -v /etc/openvpn busybox
docker run --volumes-from $OVPN_DATA --rm kylemanna/openvpn ovpn_genconfig -u udp://your.host.domain:1194
docker run --volumes-from $OVPN_DATA --rm -it kylemanna/openvpn ovpn_initpki

Set up to run at boot time via upstart

Here we configure the external listening port as 8443 (UDP) which is translated to port 1194 inside the docker container.

/etc/init/docker-openvpn.conf:

description "Docker container for OpenVPN server"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
  exec docker run --volumes-from ovpn-data --rm -p 8443:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
end script

Start the service and generate OpenVPN configs

sudo service docker-openvpn start
docker ps
docker run --volumes-from $OVPN_DATA --rm -it kylemanna/openvpn easyrsa build-client-full macbook_pro nopass

Export VPN config for import into openvpn

docker run --volumes-from $OVPN_DATA --rm kylemanna/openvpn ovpn_getclient macbook_pro > macbook_pro.ovpn

Copy the file macbook_pro.ovpn to your computer and open it with https://tunnelblick.net

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