Free VPN in 1 minute with Docker

Posted on Mar 3, 2021

In this short guide I will show you how to quickly install an OpenVPN server using an existing Docker image. It is possible to install an OpenVPN server, but with Docker everything is much easier. You don't need to buy a third party service, everything is completely free.

You must have your own VPS server. If not, you can buy a VPS on DigitalOcean. You can buy the least expensive from $2 to $5 per month.


I will use an off-the-shelf VPN solution built on Docker: https://github.com/kylemanna/docker-openvpn


All you need for the first step is to install Docker. I use Ubuntu OS.
If Docker is installed, let's move on to the next step.


I will use the following variables:

ovpn-data-example-uk - It is for data volume container.

vpn.yourdomain.com - The value should be a domain name or IP Address.

uk.vpn.yourdomain.com - It’ll be used as a client definition.


These variables are test variables. You must use your variables.



Let’s begin by creating docker volume.

docker volume create --name ovpn-data-example-uk


The next step is to initialize the container.

docker run \
    -v ovpn-data-example-uk:/etc/openvpn \
    --log-driver=none \
    --rm \
    kylemanna/openvpn \
    ovpn_genconfig \
        -u udp://vpn.yourdomain.com


The container will ask you for a passphrase to protect the private key used by the newly generated certificate authority.

docker run \
    -v ovpn-data-example-uk:/etc/openvpn \
    --log-driver=none \
    --rm \
    -it \
    kylemanna/openvpn \
    ovpn_initpki


After the previous process finished, we can start the OpenVPN server process.

docker run \
    -v ovpn-data-example-uk:/etc/openvpn \
    -d \
    -p 1194:1194/udp \
    --cap-add=NET_ADMIN \
    kylemanna/openvpn


We can generate a client certificate without a passphrase to be used on our local machine.

docker run \
    -v ovpn-data-example-uk:/etc/openvpn \
    --log-driver=none \
    --rm \
    -it \
    kylemanna/openvpn \
    easyrsa build-client-full uk.vpn.yourdomain.com nopass


After the certificate created, we can retrieve the client configuration with embedded certificates file.

docker run \
    -v ovpn-data-example-uk:/etc/openvpn \
    --log-driver=none \
    --rm \
    kylemanna/openvpn \
    ovpn_getclient uk.vpn.yourdomain.com > uk.vpn.yourdomain.com.ovpn


Download uk.vpn.yourdomain.com.ovpn to your local machine. Use OpenVPN client for Windows, or Tunnelblick for macOS, or any other VPN client for your operating system.

Comments

Anon 2021-03-07 21:30:59
> Free VPN in 1 minute with Docker > You must have your own VPS server. If not, you can buy a VPS on DigitalOcean. You can buy the least expensive from $2 to $5 per month. A good article but a more accurate title might have been 'How to setup OpenVPN with Docker'.
admin 2021-03-08 04:39:57
Thanks for the review, Anon. I will consider these suggestions in future reviews.

Leave a comment:

Thank you for your comment. After a while, our moderators will add it.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

© Twiwoo 2023 Cookie Policy