Public | Automated Build

Last pushed: 3 years ago
Short Description
OpenVPN in a container
Full Description

OpenVPN In A Docker Container

Dockerfile by jpetazzo & jfrazelle


  1. Create an config.ovpn file for the connection. Example below
  2. Place crt and key files in the same directory (or subdirectory)
  3. Run the container with network capabilities, e.g.
docker run -it --rm \
    --net host \
    --cap-add NET_ADMIN \
    --device /dev/net/tun:/dev/net/tun \
    -v "$PWD":/etc/openvpn \
fschl/openvpn:latest config.ovpn

You can replace -it --rm with -d if you don't want to keep a terminal open vor the VPN connection.

Example config.ovpn

dev tun
;proto tcp
proto udp
;remote my-server-2 1194
resolv-retry infinite

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
# Docker note: use path relative to .ovpn config file
# only in subdirectories
ca your_server_cert.crt
cert your_user_cert.crt
key your_user_key.key

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nobody

# Try to preserve some state across restarts.

Docker Pull Command
Source Repository