Difficulty: Easy
Estimated Time: 15-20 minutes

A self-hosted VPN is a simple and secure way to access your home or small business network. For small businesses, this is a great way to set up a VPN connection to allow your employees to work remote. For the rest of us, it is also a great way to secure your Internet connection when using unsecured WiFi.

For a self-hosted VPN solution, OpenVPN is one of the best and well known. It’s free and there are both desktop and mobile clients available.

With docker-compose you can make an easy and clean installation of OpenVPN, which can be easily upgraded or cleaned-up without affecting the host system and anything else installed on it.

Installing OpenVPN Server With docker-compose

Step 1 of 3

Step 1

Setup the docker-compose container

  1. Make sure that docker and docker-compose are installed:

    docker --version

    docker-compose --version

  2. Make a directory for openvpn:

    mkdir openvpn

    cd openvpn

    pwd

  3. Create docker-compose.yml like this:

    cat << EOF > docker-compose.yml
    version: '2'
    services:
      openvpn:
        cap_add:
         - NET_ADMIN
        image: kylemanna/openvpn
        container_name: openvpn
        ports:
         - "1194:1194/udp"
        restart: always
        volumes:
         - ./openvpn-data/conf:/etc/openvpn
    EOF
    

    ls

    cat docker-compose.yml

    Note: We should also make sure that the port 1194/udp is open in the firewall, for example like this: ufw allow 1194/udp.