Running the image
This image is available from Docker and GitHub registries, which is the simplest way to get it.
Note
You can not run OpenVPN and Wireguard at the same time. The VPN_CLIENT
variable allows you to choose which one.
Please see configuration for more details on all the variables in this image.
OpenVPN¶
Note
You must set at least the OPENVPN_PROVIDER
variable and provide your VPN credentials for this image to work with OpenVPN.
environment file¶
This method is cleaner since your variables are in a file versus passed at the CLI. The openvpn.env file is an example of this.
docker cli¶
all available variables¶
This example shows all variables you can use to modify the behavior of the image.
all variables
docker compose¶
docker compose
docker secrets¶
You can use docker secrets with docker compose or docker swarm. The below steps assume you're using docker compose.
Note
Docker secrets within the context of docker compose inherit the file's ownership and permissions from the host.
- remove
OPENVPN_USERNAME
andOPENVPN_PASSWORD
from the environment section of your compose file - add your credentials, username, and password each on a line in a file named
vpncreds
- ensure correct ownership and permissions of that file
vpncreds
- ensure correct ownership and permissions of that file
- add the below snippet to your compose file
compose file snippet¶
version: '3.8'
services:
docker-openvpn-client:
...
secrets:
- vpncreds
secrets:
vpncreds:
file: ./vpncreds
vpncreds file¶
Wireguard¶
Note
You must set the variable VPN_CLIENT
to wireguard
and provide a config for this image to work with Wireguard.
Wireguard is an alternative VPN client to OpenVPN. It should work on any system where the kernel module is available, except Synology, which may require additional setup.
Obtaining wireguard spk for Synology
If you're lucky you can download an SPK from here. If not, that link should help you in building your own.
You should be able to obtain a config from your VPN provider if they support it.
Info
You may see the following in the logs when running wireguard. From my testing, this hasn't caused problems, and src_valid_mark=1
is set correctly in the container.
If it does, or you want to get rid of the message, you must pass --privileged as a docker run argument. Or privileged: true
in your compose file.
docker cli¶
docker cli
docker compose¶
docker compose
misc¶
Adding PersistentKeepalive to your config may be beneficial. See the man page for more details and options.
Additional documentation¶
- docker privileged mode
- docker security
- docker supported sysctls
- wireguard manpage
- wireguard network namespace - See section under "Improved Rule-based Routing"
- kernel ip sysctl