Skip Navigation

Ripping my hair out over this, how do I make Wireguard in Docker work?

I'm a noob to self-hosting, I have set up some containers but only through watching tutorials on youtube, in reality I barely understand what I'm doing.

I have a wireguard docker container set up, but when I connect to it with my phone, there's no internet.

Can somebody tell me what I'm doing wrong? I just want to access my server outside my home network.

Here is the docker-compose.

version: "2.1" services: wireguard: image: linuxserver/wireguard container_name: wireguard cap_add: - NET_ADMIN - SYS_MODULE environment: - PUID=1000 - PGID=1000 - TZ=Asia/Singapore - SERVERURL=auto #optional - SERVERPORT=51820 #optional - PEERS=1 #optional - PEERDNS=auto #optional - INTERNAL_SUBNET=10.13.13.0 #optional volumes: - ./config:/config - /lib/modules:/lib/modules ports: - 51820:51820/udp sysctls: - net.ipv4.ip_forward=1 - net.ipv4.conf.all.src_valid_mark=1 restart: unless-stopped

Please tell me if there is anymore information I need to provide.

EDIT: fellas i figured it out, i just had to port foward 51820 on my router :sob: thank you for your help in the comments

11 comments
  • Reformatting that compose for people:

     yaml
        
    version: "2.1"                                                services:
      wireguard:
        image: linuxserver/wireguard
        container_name: wireguard
        cap_add:
          - NET_ADMIN
          - SYS_MODULE
        environment:
          - PUID=1000
          - PGID=1000
          - TZ=Asia/Singapore
          - SERVERURL=auto #optional
          - SERVERPORT=51820 #optional
          - PEERS=1 #optional
          - PEERDNS=auto #optional
          - INTERNAL_SUBNET=10.13.13.0 #optional
        volumes:
          - ./config:/config
          - /lib/modules:/lib/modules
        ports:
          - 51820:51820/udp
        sysctls:
          - net.ipv4.ip_forward=1
          - net.ipv4.conf.all.src_valid_mark=1
        restart: unless-stopped
    
      

    Sounds like you didn't read the extended manual: https://github.com/linuxserver/docker-wireguard

    There are a lot of other configs for that container that must be provided before startup. It's just a generic runner. If you want it to run as a server you need to follow this section: https://github.com/linuxserver/docker-wireguard?tab=readme-ov-file#server-mode

  • EDIT: My suggestion probably doesn't work for your use-case, but I'll leave it for anyone else....

    I use this to only tunnel the ports I actually need: https://github.com/DigitallyRefined/docker-wireguard-tunnel

    My CGNAT'ed home PC is the client, and my public-facing Oracle Cloud instance is the server.

    I've tried and failed miserably to use the "official" Wireguard container. Once I start reading suggestions to modify iptables outside of Docker, I know I'm in trouble.

11 comments