Run OpenVPN Access Server in Docker
OpenVPN Access Server is a self-hosted VPN solution with a web administration interface. This version keeps the source ports, volume, and operation order while separating commands and adding practical safety notes.
Install Docker on Linux
Log into Linux with a sudo-capable account and run the commands below. The source uses apt-key; on a current distribution, also check the official Docker installation documentation because this command is deprecated.
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -ycurl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"sudo apt install docker-ce docker-compose containerd.io -ysudo systemctl enable docker && sudo systemctl start dockersudo usermod -aG docker $USERsu - $USER
Run the OpenVPN Access Server container
Create the data directory and start the container. NET_ADMIN is required for VPN functions, so do not run this container on an uncontrolled host.
mkdir ~/docker/openvpn-as -pdocker run -d --name openvpn-as \ --cap-add=NET_ADMIN \ -p 943:943 \ -p 8443:443 \ -p 1194:1194/udp \ -v ~/docker/openvpn-as:/openvpn \ openvpn/openvpn-as
Read the temporary password generated by the container:
docker logs openvpn-as | grep 'Auto-generated pass'
Copy the value on the Auto-generated pass = line locally. Do not put the real password in Git or send it through chat.
Sign in and replace the password
- Open
https://DNSorIP:943/admin. The initial certificate may be self-signed. - Sign in as
openvpnwith the password from the log. - Click Agree to accept the EULA.
- Choose User Management > User Permissions.
- Click the edit icon beside
openvpn. - Enter a new Password and click Save Settings.
- Click Logout, then sign in again with the new password.
- Check the container with
docker psanddocker logs --tail=50 openvpn-as.
The ports are 943:943 for web access, 8443:443 for HTTPS, and 1194:1194/udp for VPN. Expose them through firewall/NAT rules only when required.
Sources and video
- Original tutorial: i12bretro 0946
- Original video: Run OpenVPN Access Server in Docker
Comments & Discussion
Share your thoughts, ask questions and feedback