Prepare
sudo mkdir -p /opt/wireguard/config
sudo nano /opt/wireguard/docker-compose.yml
docker-compose.yml
content:
---
services:
wireguard:
image: lscr.io/linuxserver/wireguard
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- SERVERURL=auto #optional
- SERVERPORT=51820 #optional
- PEERS=10 #optional
- PEERDNS=auto #optional
- INTERNAL_SUBNET=10.10.10.0 #optional
- ALLOWEDIPS=0.0.0.0/0 #optional
volumes:
- /opt/wireguard/config:/config
- /lib/modules:/lib/modules
ports:
- 51820:51820/udp
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
restart: unless-stopped
Run
cd /opt/wireguard
sudo docker compose up -d
Show QR to connect
sudo docker exec -it wireguard /app/show-peer 1
Config to use on client /opt/wireguard/config/peerX/peerX.conf
(where X is a serial number starting with 1)