> ## Content Index
> Fetch the complete content index at: https://blog.lolmate.duckdns.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# WireGuard VPN on an Oracle Cloud VPS with Docker
- URL: https://blog.lolmate.duckdns.org/wireguard-vpn-on-an-oracle-cloud-vps-with-docker/
- Published: 2026-11-29T16:05:15.000Z
- Updated: 2026-11-29T16:05:15.000Z
- Author: Umer Farooq

A free-tier Oracle Cloud VM in the right country turns into a private WireGuard VPN in about 15 minutes, and Docker keeps the whole setup in one folder you can move to another host later.

This guide shows how to run WireGuard in a container on an Ubuntu VM and connect to it from Windows. The result: your traffic exits from the VM's region, so you can reach content that is tied to that location.

## What you need

- An Oracle Cloud VM running Ubuntu, in the region whose content you want (ARM and x86 both work)
- SSH access to the VM
- A Windows PC
- The VM's public IP address

## Step 1: Open UDP port 51820 in Oracle Cloud

Oracle blocks incoming traffic by default, so add an ingress rule to the security list (or network security group) attached to your VM's subnet:

| Field                  | Value             |
| ---------------------- | ----------------- |
| Source CIDR            | 0.0.0.0/0         |
| IP protocol            | UDP               |
| Source port range      | leave blank (all) |
| Destination port range | 51820             |

Only the destination port matters. The source port is chosen randomly by the client, so leave it open.

## Step 2: Install Docker on the VM

SSH into the VM and install Docker with the official script, then add your user to the docker group:

```bash
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
```

Log out and back in so the group change applies.

## Step 3: Create the compose file and start WireGuard

The linuxserver.io image generates the server keys and a ready-made client config for you. Create a folder and a `docker-compose.yml` inside it:

```bash
mkdir ~/wireguard && cd ~/wireguard
nano docker-compose.yml
```

```yaml
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard:latest
    container_name: wireguard
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - SERVERURL=YOUR_VM_PUBLIC_IP
      - SERVERPORT=51820
      - PEERS=1
      - PEERDNS=auto
      - INTERNAL_SUBNET=10.13.13.0
      - ALLOWEDIPS=0.0.0.0/0
    volumes:
      - ./config:/config
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: unless-stopped
```

Replace `YOUR_VM_PUBLIC_IP` with your VM's address, then start it:

```bash
docker compose up -d
docker logs wireguard | tail -20
```

`ALLOWEDIPS=0.0.0.0/0` sends all of your traffic through the VPN. `PEERS=1` creates one client, which is enough for a single device.

## Step 4: Connect from Windows

The container writes your client config to `~/wireguard/config/peer1/peer1.conf`. The folder is owned by root, so read it with `sudo`:

```bash
sudo cat ~/wireguard/config/peer1/peer1.conf
```

Then on your PC:

1. Install the official WireGuard app from [wireguard.com/install](https://www.wireguard.com/install/?ref=blog.lolmate.duckdns.org).
2. Click **Add Tunnel**, then **Add empty tunnel**.
3. Replace the generated text with the config you copied, name the tunnel and click **Save**.
4. Click **Activate**.
5. Open a site such as ifconfig.me. It should show your VM's public IP and region.

The config contains your private key. Never post it publicly, and if it leaks, delete `config/peer1` and the server folder under `config`, then run `docker compose up -d` to regenerate everything.

## Caveats and troubleshooting

Some streaming services still block you, because Oracle's IP ranges are known datacenter addresses. That is a property of the IP, not a fault in your setup.

- **No handshake:** recheck the Oracle ingress rule (UDP 51820) and the container logs with `docker logs wireguard`.
- **Connected but no internet:** the container sets up NAT itself, so check that Docker is running and that the `Endpoint` in your client config matches the VM's public IP.
- **Wrong DNS or slow lookups:** set `DNS = 1.1.1.1` in the client config instead of the container's DNS.

## Moving to another server

Everything lives in one folder, so migration is a backup and a restore. On the old VM:

```bash
sudo tar czf wg-backup.tgz -C ~/wireguard .
```

On the new VM, install Docker, extract the archive into `~/wireguard` with `sudo tar xzf`, update `SERVERURL` in `docker-compose.yml` to the new IP, open UDP 51820 in that provider's firewall, and run `docker compose up -d`. Change the `Endpoint` in your client config to the new IP, since the old one no longer applies.