Skip to content
Deploy an OpenVPN container in one step
Makefile Dockerfile Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

OpenVPN in a container

The goal of this project is to provide a hassle-free OpenVPN experience for anyone, certificates and keys are created and managed within the container and both client and server are configured with sane values. With docker-openvpn you can spin up a new OpenVPN server in less than a minute.

Automatic deployment (with ansible)

Install Ansible 2.8+ in your localhost.

ansible-playbook --version
# ansible-playbook 2.8.1
#   config file = /etc/ansible/ansible.cfg

Make sure you have root access to a remote host (like and install docker on it.

Clone this repo:

cd ~/projects
git clone

Get into the docker-openvpn directory and run make deploy, pass a REMOTE_HOST environment variable that matches the IP/FQDN of the remote server:

cd docker-openvpn
REMOTE_HOST= make deploy

Wait a few seconds while your OpenVPN server gets configured.

Once the command finishes, you'll have a client.ovpn file on your localhost that you can use to connect to your shiny new OpenVPN server:

openvpn --config client.ovpn

Check if you exit IP changed after connecting to the VPN:


For each client you want to add set a CLIENT_NAME env var and run make deploy again, don't forget to set REMOTE_HOST as well:

CLIENT_NAME=mba13 REMOTE_HOST= make deploy
# cat mba13.ovpn


VPN clients

The .ovpn file generated by docker-openvpn is compatible with any OpenVPN client as well as with the standard openvpn CLI.

Similar projects

You can’t perform that action at this time.