The compose file I actually ran, with the three fixes the circulating instructions leave out:
a bcrypt PASSWORD_HASH, $$-escaped $ in .env, and the admin
panel bound to loopback. No keys, no password, no client configs in here — generate your own.
Before you run this: it only works if the machine stays at home, awake, and the
router has a public IPv4 to forward UDP 51820 to. A WAN address starting 100.64,
10. or 172.16–31 is carrier-grade NAT and there is no port to forward.
services:
wg-easy:
image: ghcr.io/wg-easy/wg-easy:latest
container_name: wg-easy
restart: unless-stopped
env_file:
- .env
environment:
- WG_PORT=51820
- INSECURE=true # plain HTTP admin UI; loopback-bound below
volumes:
- etc_wireguard:/etc/wireguard
ports:
- "51820:51820/udp" # the tunnel
- "127.0.0.1:51821:51821/tcp" # admin UI, this machine only
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
volumes:
etc_wireguard:
WG_HOST=<home public IP or DNS name> PASSWORD_HASH=$$2a$$12$$<bcrypt hash>
PASSWORD= aborts the container with an explicit error. v14 wants a bcrypt
PASSWORD_HASH, generated inside the image.
compose interpolates .env values, so an unescaped hash becomes $2a$12$ and
blanks. The app then reports no password required and the panel is open.
The admin panel is not part of the VPN. Forward only 51820/udp; reach the UI over SSH
or sit at the box.
WireGuard adds ~60 bytes per packet, so wg-quick drops the interface MTU to
1500 − 80 to avoid fragmentation.