Run a VPN in a Docker container using SoftEther
This tutorial uses the siomiz/softethervpn Docker image to launch a SoftEther VPN server inside a Docker container. You can then connect to this VPN from your desktop or laptop computer, and use it to access the Internet through a secure tunnel. This method is fast and easy, and requires you to run only one command on your server.
SoftEther has clients available for Windows, Linux, and Mac OS. This allows you to browse the Internet securely even if you are on an unsecured wifi connection. It is an excellent security solution for those who travel often, or who work from public internet connections such as those found in coffee shops and public libraries.
- A Cloud Server running Linux (CentOS 7 or Ubuntu 16.04)
- A fully-qualified domain name (example.com).
- Docker installed and running.
For information on getting started with Docker, see our article Installing and Running Docker on a Linux Server.
If you have a firewall, you will need to allow access to the following ports:
- UDP: 500
- UDP: 4500
- TCP: 1701
- TCP: 5555
Start the Docker container
Launch a Docker container running SoftEther with the following command:
sudo docker run -d -p 500:500/udp -p 4500:4500/udp -p 1701:1701/tcp -p 1194:1194/udp -e PSK=[passphrase] -e USERNAME=[your VPN username] -e PASSWORD=[your VPN password] siomiz/softethervpn
For example, to set up the SoftEther VPN server with the passphrase En4EW25eI0, username jdoe, and password Qt0JYyx07E, the command is:
sudo docker run -d -p 500:500/udp -p 4500:4500/udp -p 1701:1701/tcp -p 1194:1194/udp --name softether-vpn -e PSK=En4EW25eI0 -e USERNAME=jdoe -e PASSWORD=Qt0JYyx07E siomiz/softethervpn
After the command has completed, you can verify that the container is running with the command:
sudo docker ps
The server will respond with a list of all active Docker containers:
[user@localhost ~]# sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4fca9ead3e14 siomiz/softethervpn "/entrypoint.sh /u..." 50 seconds ago Up 49 seconds 0.0.0.0:500->500/udp, 0.0.0.0:1701->1701/tcp, 0.0.0.0:4500->4500/udp, 1194/udp, 0.0.0.0:5555->5555/tcp softether-vpn
vServer (VPS) from IONOS
Low-cost, powerful VPS hosting for running your custom applications, with a personal assistant and 24/7 support.
Connect to the VPN server
In order to connect to the SoftEther VPN server in your Docker container, you will need to download and install the SoftEther client on your desktop or laptop computer.
Download the appropriate installer from the SoftEther download page and follow the instructions to install the SoftEther client.
To configure the VPN connection on Windows, double-click Add VPN Connection.
You will be connected to the VPN.
To verify that you are on the VPN, go to a website such as WhatIsMyIPAddress.com. If you are connected to the VPN, this website will see the IP address of your server, not the IP or MAC address of your computer.