Self-Host Your Own VPN with wg-easy — WireGuard in One Docker Container

Tested · wg-easy v14 line (ghcr.io/wg-easy/wg-easy:latest) · 2026-11-21Beginner · ~10 min hands-on · 5 min readLine C

This page contains affiliate links. If you buy through them we may earn a commission — it never affects our rankings or scores. How we make money

Watch on YouTube ↗ — if the player asks you to sign in, YouTube is flagging your network; the video itself is public and plays on YouTube directly.

On this page

WireGuard is the fastest modern VPN protocol, and wg-easy is the easiest way to run it yourself: one Docker container, one web panel, and every device you own connected in a few clicks. No subscription, no third party logging your traffic — your server, your VPN.

In this guide we install wg-easy with Docker Compose on the same server that already runs our Coolify and Cal.com stack, create a client for a laptop, and verify the tunnel with a live handshake. Everything below was tested end to end on 2026-11-21, including the two gotchas that stop most first installs.

What you need

  • A server with Docker and Docker Compose installed (we use the server from the earlier episodes in this series)
  • A subdomain pointing at the server — ours is wg.deploysaga.com
  • UDP port 51820 reachable on the server (the tunnel itself runs over UDP)

If you need a server, we run this series on an InterServer VPS — the first slice is about $3/month and is plenty for a personal VPN. Any other VPS works exactly the same way; wg-easy and WireGuard are both free and open source either way.

Step 1 — Generate the panel password hash

The wg-easy panel is protected by a password, and the password is never stored in plain text. The project ships a helper that converts your password into a bcrypt hash:

mkdir -p ~/wg-easy && cd ~/wg-easy
sudo docker run --rm ghcr.io/wg-easy/wg-easy:latest wgpw 'YourPanelPassword'

It prints a line like:

PASSWORD_HASH='$2a$12$....'

Copy the hash — you will paste it into the Compose file next. Two things to know:

  • In the Compose file, every $ in the hash must be doubled to $$. Docker Compose treats $ as a variable reference, so a hash pasted in raw gets mangled and your password will never match.
  • Pick a real password here. This one guards the panel that mints VPN keys.

Step 2 — Write the Compose file

Create docker-compose.yml in ~/wg-easy:

services:
  wg-easy:
    image: ghcr.io/wg-easy/wg-easy:latest
    container_name: wg-easy
    environment:
      - WG_HOST=wg.example.com
      - PASSWORD_HASH=$$2a$$12$$replace-with-your-hash
      - PORT=51821
      - WG_PORT=51820
    volumes:
      - wg-etc:/etc/wireguard
      - /lib/modules:/lib/modules:ro
    ports:
      - "51820:51820/udp"
      - "51821:51821/tcp"
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1

volumes:
  wg-etc:

The lines that matter:

  • WG_HOST is required. It is the public address your devices will dial, so set it to your subdomain. Leave it out and the container crash-loops with WG_HOST Environment Variable Not Set! — this is the single most common wg-easy install failure.
  • Two ports: 51820/udp carries the tunnel, 51821/tcp serves the web panel.
  • The named volume wg-etc keeps the server keys and every client configuration safe across restarts and container updates.
  • NET_ADMIN / SYS_MODULE and the ip_forward sysctl are what let the container create the WireGuard interface and route traffic.

Start it:

sudo docker compose up -d
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:51821/

A 200 means the panel is up.

Step 3 — Sign in to the panel

Open http://wg.example.com:51821 and sign in with the password you hashed in Step 1.

One honest warning: the panel itself is plain HTTP. On a real server, only open it on your own network, or put it behind a reverse proxy with HTTPS. Never publish the raw panel to the internet — anyone who reaches it can try to brute-force the one password that controls your whole VPN. The tunnel port (51820/udp) is the only thing that needs to face the public internet.

Step 4 — Create a client

  1. Click New Client and give the device a name — ours is my-laptop.
  2. That is the entire server-side setup. wg-easy generates the keys and assigns the device its own tunnel address (ours got 10.8.0.2).

Every phone, tablet, and laptop you own gets its own client, and you can disable or delete any of them with one click if a device is lost.

Step 5 — Download the configuration

Click the download icon on the client card to save the configuration as a small .conf text file.

Gotcha: because the panel is served over HTTP, Chrome blocks the download at first with "Insecure download blocked". Click Keep and the file saves normally. (Serving the panel over HTTPS removes this, which is one more reason to reverse-proxy it in production.)

Treat this file like a password: whoever holds it, holds a working key to your VPN. On a phone you would skip the file entirely and scan the QR code shown by the QR icon on the same card.

Step 6 — Connect the laptop

  1. Install the official WireGuard app (free, every platform) on the device.
  2. Choose Import tunnel(s) from file and pick the .conf you just downloaded.
  3. The tunnel appears with the server endpoint (wg.example.com:51820) and full-tunnel routing (0.0.0.0/0) already filled in.
  4. Click Activate.

You should see Status: Active, a latest handshake a few seconds old, and transfer counters starting to move. From this moment, every page the laptop loads travels through your own server first.

Step 7 — Verify in the panel

Back in the wg-easy panel, the client card now shows live throughput (current up/down rates plus total transferred) for the connected device. If the card shows traffic and the app shows a fresh handshake, the VPN is fully working — not just configured.

Gotchas we hit, so you don't have to

  • Container crash-loops on first start → WG_HOST is missing. It is mandatory, not optional.
  • Password never accepted → the hash in the Compose file lost its $ characters. Double every $ to $$.
  • Download blocked by Chrome → expected over HTTP; click Keep. It is a browser protection, not a wg-easy error.
  • Tunnel connects but no traffic flows → check that UDP 51820 actually reaches the server (cloud firewall / security group), and that net.ipv4.ip_forward is 1 on the host.
  • Panel exposed to the internet → don't. Restrict 51821 to your LAN or a reverse proxy; only 51820/udp needs to be public.

What's next

Your private VPN is live: one container, one panel, every device a few clicks away. In the next episode we try a different take on the same job — Outline, the VPN designed for sharing access with other people.

DeploySaga deskEvery step run hands-on from a clean install — no vendor screenshots, no copied docs.