wg-easy with Docker Compose
You have found the easiest way to install & manage WireGuard on any Linux host! All-in-one: WireGuard + Web UI. In the project's words: wg-easy README on GitHub checked 2026-09-26
Runs on: amd64, arm64 from each image's registry manifest, checked 2026-09-26; a CPU counts only if every image has a build for it. Image by image
Add wg-easy to the builder to use your own domain and combine it with other apps in one file.
What wg-easy needs
Only figures wg-easy's own documentation publishes, each linked to the page it is on. Where the project gives no number, this page does not invent one.
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | Not published by the project | |
| CPU | Not published by the project | |
| Disk | Not published by the project | |
Which hardware wg-easy has images for
Read from each image's manifest list in its registry (anonymous, read-only) when this page was built. An app counts for a CPU only if every one of its images lists it.
- x86-64 PC or NAS (
linux/amd64): every image has a build. - Raspberry Pi 4/5, 64-bit OS (
linux/arm64): every image has a build. - Raspberry Pi 3 or Zero 2 W, 32-bit OS (
linux/arm/v7): no image forwg-easy. No image for this hardware; the builder leaves the app out.
| Service | Image | Platforms in the manifest | Digest | Registry | Checked |
|---|---|---|---|---|---|
wg-easy | ghcr.io/wg-easy/wg-easy:15 | arm64, amd64 | sha256:0e7bc9d34e86ddcaa92bc700d4d7dc9b33291dbc07ac8d13382f7c2095f949ec | ghcr.io | 2026-09-26 |
docker-compose.yml
This is exactly what the builder writes for wg-easy alone on example.org: the official definition with its published ports removed except 51820:51820/udp, which cannot go through a web proxy (see below), and Caddy added in front.
# docker-compose.yml built at dankhost.com for: wg-easy
# Each app block is its official compose definition. Only the names were prefixed with
# the app slug (services, containers, volumes, bind folders, .env variables) so any set of
# apps can share one file; other differences are listed under "Changed:" in each block.
# Caddy publishes 80 and 443. The only other published ports, each labelled where
# it is written: 51820/udp (wg-easy: WireGuard).
# Secrets live in .env next to this file.
services:
# ---- Caddy: the one reverse proxy, HTTPS certificates from Let's Encrypt ----
# Source: https://caddyserver.com/docs/running (checked 2026-09-23)
# Source: https://github.com/dani-garcia/vaultwarden/wiki/Using-Docker-Compose (checked 2026-09-23)
# Caddyfile goes in ./caddy/Caddyfile. Fixed address 172.30.0.2 so apps can trust it exactly.
caddy:
image: "caddy:2"
container_name: "caddy"
restart: "unless-stopped"
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- "./caddy:/etc/caddy"
- "caddy-data:/data"
- "caddy-config:/config"
networks:
proxy:
ipv4_address: "172.30.0.2"
# ---- wg-easy (vpn.example.org) ----
# Source: https://github.com/wg-easy/wg-easy/blob/master/docker-compose.yml (checked 2026-09-26)
# Source: https://wg-easy.github.io/wg-easy/latest/examples/tutorials/basic-installation/ (checked 2026-09-26)
# Source: https://wg-easy.github.io/wg-easy/latest/examples/tutorials/caddy/ (checked 2026-09-26)
# Source: https://wg-easy.github.io/wg-easy/latest/getting-started/ (checked 2026-09-26)
# Source: https://wg-easy.github.io/wg-easy/latest/examples/tutorials/traefik/ (checked 2026-09-26)
# Changed: Removed the '51821:51821/tcp' port, as wg-easy's Caddy guide does; Caddy reaches wg-easy:51821 (the web UI's default PORT) on the proxy network. '51820:51820/udp' stays: it is the VPN.
# The documented wg network (10.42.42.0/24 and fdcc:ad94:bacf:61a3::/64, with the container's fixed addresses) is kept, named wg-easy-wg; the container also joins the proxy network, as the Caddy guide adds the caddy network.
# PORT OUTSIDE THE PROXY 51820/udp: the VPN itself: your phones and laptops connect here. WireGuard runs over UDP, not HTTP, so it cannot go through the proxy; wg-easy's installation page says to open UDP 51820.
# ELEVATED ACCESS (cap_add NET_ADMIN, SYS_MODULE, sysctls, /lib/modules): kept from the documented file. NET_ADMIN lets the container create the WireGuard interface and set its routes and firewall rules; the sysctls turn on IP forwarding inside its own network. SYS_MODULE with the read-only /lib/modules lets it load the wireguard module into the host kernel, which is as powerful as root on the host. If "lsmod | grep wireguard" on the server already shows the module, you can remove SYS_MODULE and the /lib/modules mount.
wg-easy:
image: "ghcr.io/wg-easy/wg-easy:15"
container_name: "wg-easy"
volumes:
- "wg-easy-etc_wireguard:/etc/wireguard"
- "/lib/modules:/lib/modules:ro"
restart: "unless-stopped"
cap_add:
- "NET_ADMIN"
- "SYS_MODULE"
sysctls:
- "net.ipv4.ip_forward=1"
- "net.ipv4.conf.all.src_valid_mark=1"
- "net.ipv6.conf.all.disable_ipv6=0"
- "net.ipv6.conf.all.forwarding=1"
- "net.ipv6.conf.default.forwarding=1"
ports:
- "51820:51820/udp" # WireGuard
networks:
proxy: {}
wg-easy-wg:
ipv4_address: "10.42.42.42"
ipv6_address: "fdcc:ad94:bacf:61a3::2a"
networks:
# Pinned so the trusted-proxy address given to each app (172.30.0.2) is exact.
# If "docker compose up" reports "Pool overlaps", change 172.30.0 here, in Caddy's
# ipv4_address and in every trusted-proxy value to a free 172.x.0 range.
proxy:
ipam:
config:
- subnet: "172.30.0.0/24"
ip_range: "172.30.0.128/25"
gateway: "172.30.0.1"
wg-easy-wg:
driver: "bridge"
enable_ipv6: true
ipam:
driver: "default"
config:
- subnet: "10.42.42.0/24"
- subnet: "fdcc:ad94:bacf:61a3::/64"
volumes:
caddy-data:
caddy-config:
wg-easy-etc_wireguard:
Caddyfile save as caddy/Caddyfile
Caddy gets and renews the HTTPS certificate for vpn.example.org by itself once the DNS record points at your server and ports 80 and 443 reach it.
# Caddyfile built at dankhost.com. Save it as ./caddy/Caddyfile next to docker-compose.yml.
# Caddy gets and renews a Let's Encrypt certificate for each name below by itself,
# once the DNS records point at this server and ports 80 and 443 reach it.
# wg-easy
vpn.example.org {
reverse_proxy wg-easy:51821
}
.env
wg-easy needs no secret here; the builder adds nothing you have to fill in by hand.
# .env for wg-easy, from dankhost.com/app/wg-easy/. Nothing here is secret. # Keep this file private (chmod 600). # None of the chosen apps needs a variable here.
What wg-easy needs beyond the proxy
Every other app in the builder is reached only through the proxy on ports 80 and 443. wg-easy also needs this port on the server itself, because it carries traffic that is not HTTP. The compose file labels it with a # PORT OUTSIDE THE PROXY comment.
51820:51820/udp(WireGuard): the VPN itself: your phones and laptops connect here. WireGuard runs over UDP, not HTTP, so it cannot go through the proxy; wg-easy's installation page says to open UDP 51820.- Forward UDP 51820 from your router to this server. VPN clients connect to it directly from the internet, not through the proxy.
wg-easy asks for more than an ordinary container. The compose file keeps what the project documents and labels each item with an # ELEVATED ACCESS comment; /check/ flags it too, as it would in any file.
- cap_add NET_ADMIN, SYS_MODULE, sysctls, /lib/modules: kept from the documented file. NET_ADMIN lets the container create the WireGuard interface and set its routes and firewall rules; the sysctls turn on IP forwarding inside its own network. SYS_MODULE with the read-only /lib/modules lets it load the wireguard module into the host kernel, which is as powerful as root on the host. If "lsmod | grep wireguard" on the server already shows the module, you can remove SYS_MODULE and the /lib/modules mount.
Changes from the official file
Besides prefixing every service, container, volume, folder and variable with wg-easy (so any set of apps can share one file), these are all the differences from what the project documents:
- Removed the '51821:51821/tcp' port, as wg-easy's Caddy guide does; Caddy reaches wg-easy:51821 (the web UI's default PORT) on the proxy network. '51820:51820/udp' stays: it is the VPN.
- The documented wg network (10.42.42.0/24 and fdcc:ad94:bacf:61a3::/64, with the container's fixed addresses) is kept, named wg-easy-wg; the container also joins the proxy network, as the Caddy guide adds the caddy network.
Notes for wg-easy behind the proxy
- Open https://vpn.example.org and follow the setup wizard: it creates the admin account and asks for the host and port your clients connect to. Give your domain (or the server's public IP address) and port 51820.
- The web UI arrives over HTTPS through Caddy, so wg-easy's default INSECURE=false stays.
- wg-easy's Getting Started page says to use "docker compose up" and "down", not "start" and "stop", or the container is not properly destroyed and the next start can fail. After changing anything, run: docker compose up -d --force-recreate wg-easy
How to run it
- At your DNS provider, add an A record named
vpnon your domain pointing at the server's public IP address, and forward TCP 80, TCP 443 and UDP 443 to it. For wg-easy, forward UDP 51820 from your router to this server. VPN clients connect to it directly from the internet, not through the proxy. - Save the three files in one folder:
docker-compose.ymland.envside by side, the Caddyfile at./caddy/Caddyfile. Replaceexample.orgwith your domain in the Caddyfile, the compose file and the .env, or let the builder do it. - Nothing in
.envneeds filling in;chmod 600 .envall the same. - Start it:
docker compose up -d docker compose logs -f caddy # watch the certificate arrive
- Open the new address (
vpn.plus your domain) in a browser and follow the notes above.
Back it up
wg-easy keeps everything in /etc/wireguard, the documented named volume etc_wireguard: its database with the server and client keys and settings. /lib/modules is the host's, mounted read-only.
Below is the BACKUP.md the builder writes next to the compose file above: which of its folders and volumes hold data, what to copy with which container stopped, and a restore check. Pick more apps in the builder and it covers them all in one file.
# BACKUP.md built at dankhost.com for: wg-easy
What to copy from the docker-compose.yml built with this file, the database dump each project documents (rewritten for the service names in that file), what to copy with which container stopped, and how to check the result. Run every command in the folder that holds docker-compose.yml.
The folders are owned by the containers' users: put sudo in front of tar if it says "Permission denied". Named volumes live under /var/lib/docker/volumes, not next to the compose file, so they are copied through a throwaway ubuntu container (Docker's documented --volumes-from method). tar makes a full copy each run; for large folders an incremental tool (restic, borg, rsync) saves time and space.
Never run "docker compose down -v" on this file: it deletes the named volumes of every app in it.
## Before you start
BACKUP=/mnt/backup/selfhost # change this: a disk or machine other than this server's system disk
mkdir -p "$BACKUP"
## Every time: the three stack files
tar czf "$BACKUP/stack-files.tar.gz" docker-compose.yml .env caddy
.env holds the database passwords and secret keys the apps were set up with; keep this archive as private as the data.
## Caddy (the reverse proxy)
Caddy's docs: 'The data directory must not be treated as a cache.' It holds the TLS certificates and their private keys; without it Caddy has to ask Let's Encrypt for every certificate again.
- caddy-data (named volume, /data in caddy)
BACK UP: TLS certificates, private keys, OCSP staples.
- caddy-config (named volume, /config in caddy)
SKIP: the last active configuration, kept for 'caddy run --resume', which this setup does not use: it starts from the Caddyfile.
- ./caddy (/etc/caddy in caddy)
IN stack-files.tar.gz: the Caddyfile, copied with the stack files above.
Copy (Caddy keeps serving while you copy):
docker run --rm --volumes-from caddy -v "$BACKUP":/backup ubuntu tar cvf /backup/caddy-data.tar /data
Restore check:
tar tf "$BACKUP/caddy-data.tar" > /dev/null && echo OK
docker run --rm --volumes-from caddy -v "$BACKUP":/backup ubuntu bash -c "cd /data && tar xvf /backup/caddy-data.tar --strip 1"
Sources:
- Caddy docs: Conventions, Data directory: https://caddyserver.com/docs/conventions#data-directory (checked 2026-09-24)
- Docker docs: Volumes, Back up, restore, or migrate data volumes: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes (checked 2026-09-24)
## wg-easy
wg-easy keeps everything in /etc/wireguard, the documented named volume etc_wireguard: its database with the server and client keys and settings. /lib/modules is the host's, mounted read-only.
What this compose mounts:
- wg-easy-etc_wireguard (named volume, /etc/wireguard in wg-easy)
BACK UP: the server and client keys, client list and settings.
1. Stop wg-easy. Stopping it keeps its database from changing mid-copy. VPN clients are disconnected until it is back.
docker compose stop wg-easy
2. Copy while wg-easy is stopped:
docker run --rm --volumes-from wg-easy -v "$BACKUP":/backup ubuntu tar cvf /backup/wg-easy-etc_wireguard.tar /etc/wireguard
3. Start it again:
docker compose up -d --force-recreate wg-easy
Restore check:
tar tf "$BACKUP/wg-easy-etc_wireguard.tar" > /dev/null && echo OK
Put a copy back (with wg-easy stopped):
docker run --rm --volumes-from wg-easy -v "$BACKUP":/backup ubuntu bash -c "cd /etc/wireguard && tar xvf /backup/wg-easy-etc_wireguard.tar --strip 2"
Put the volume back with the command above (wg-easy stopped), then start it with: docker compose up -d --force-recreate wg-easy
Sources:
- wg-easy docs: Getting Started (tag 15, use docker compose up/down, not start/stop): https://wg-easy.github.io/wg-easy/latest/getting-started/ (checked 2026-09-26)
- Docker docs: Volumes, Back up, restore, or migrate data volumes: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes (checked 2026-09-26)
Sources
Every page below was fetched on the date shown.
- wg-easy README on GitHub checked 2026-09-26 (what it does)
- wg-easy: docker-compose.yml (the file the basic installation downloads) checked 2026-09-26 (compose definition and proxy settings)
- wg-easy docs: Basic Installation (download the compose file, open UDP 51820) checked 2026-09-26 (compose definition and proxy settings)
- wg-easy docs: Caddy (drop the web UI port, keep 51820/udp, join the proxy network) checked 2026-09-26 (compose definition and proxy settings)
- wg-easy docs: Getting Started (tag 15, use docker compose up/down, not start/stop) checked 2026-09-26 (compose definition and proxy settings, backup plan)
- wg-easy docs: Traefik (labels with loadbalancer.server.port=51821, the traefik network) checked 2026-09-26 (compose definition and proxy settings)
- Caddy docs: Keep Caddy running (Docker Compose section) checked 2026-09-23 (Caddy)
- Vaultwarden wiki: Caddy with HTTP challenge (uses the caddy:2 image) checked 2026-09-23 (Caddy)
- Docker docs: Volumes, Back up, restore, or migrate data volumes checked 2026-09-26 (backup plan)
- Caddy docs: Conventions, Data directory checked 2026-09-24 (backup plan)