Skip to content

tetafro/openvpn

Repository files navigation

Docker OpenVPN

Release

OpenVPN with a simple init process inside a docker container.

Server

Make a directory for OpenVPN configs. Start a docker container and mount configs directory as a volume.

mkdir vpn
cd vpn
docker run --detach \
    --privileged \
    --restart unless-stopped \
    --publish 1194:1194/udp \
    --volume $(pwd):/etc/openvpn \
    --name openvpn \
    ghcr.io/tetafro/openvpn

Clients

Generate a new client config file (you can generate as many as you want):

docker exec -it openvpn /vpn/vpn.sh add-client

The above command will generate client_N.conf file, which is a full config with a private key and certificates. Just take it to your client machine and run with your client app.

Ubuntu example:

scp your-vpn-server:/home/user/vpn/client.conf .
sudo apt install openvpn openvpn-systemd-resolved
sudo openvpn --config client.conf

Development

docker build -t localhost/openvpn .
docker run --rm -it \
    --privileged \
    --publish 1194:1194/udp \
    --volume $(pwd)/conf:/etc/openvpn \
    --name openvpn \
    localhost/openvpn
docker exec -it openvpn /vpn/vpn.sh add-client

Original project