Wireguard client container doesn't connect

Hello, I’m trying to use the Wireguard container via docker-compose but I’ve having issue having to establish a working VPN connection. I’m using Mullvad as my VPN provider. I’m running Windows 10 Pro.

This is my docker-compose wireguard configuration:

version: "3.6"
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Brussels
    volumes:
      - C:\Users\Issam\OneDrive\IT Files\Docker\Wireguard:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
      - 55335:55335
      - 55335:55335/udp
      - 8080:8080
      - 8989:8989
      - 7878:7878
      - 9117:9117
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: always

I’ve dropped my client conf into the config folder as /config/wg0.conf. This is my wg0.conf:

[Interface]
PrivateKey = myprivatekey
Address = 10.64.69.115/32
PostUp = systemd-resolve -i %i --set-dns=193.138.218.74 --set-domain=~.

[Peer]
PublicKey = mypublickey
AllowedIPs = 0.0.0.0/0
Endpoint = 185.65.134.223:51820

And finally, this is the docker log:

-------------------------------------

          _         ()

         | |  ___   _    __

         | | / __| | |  /  \ 

         | | \__ \ | | | () |

         |_| |___/ |_|  \__/



Brought to you by linuxserver.io

-------------------------------------


To support the app dev(s) visit:

WireGuard: https://www.wireguard.com/donations/


To support LSIO projects visit:

https://www.linuxserver.io/donate/

-------------------------------------

GID/UID

-------------------------------------


User uid:    1000

User gid:    1000

-------------------------------------


[cont-init.d] 10-adduser: exited 0.

[cont-init.d] 30-module: executing... 

Uname info: Linux bfa4b84002cf 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

**** It seems the wireguard module is already active. Skipping kernel header install and module compilation. ****

[cont-init.d] 30-module: exited 0.

[cont-init.d] 40-confs: executing... 

**** Client mode selected. ****

**** Disabling CoreDNS ****

[cont-init.d] 40-confs: exited 0.

[cont-init.d] 90-custom-folders: executing... 

[cont-init.d] 90-custom-folders: exited 0.

Warning: `/config/wg0.conf' is world accessible

[#] ip link add wg0 type wireguard

[#] wg setconf wg0 /dev/fd/63

[#] ip -4 address add 10.64.69.115/32 dev wg0

[#] ip link set mtu 1420 up dev wg0

[#] wg set wg0 fwmark 51820

[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820

[#] ip -4 rule add not fwmark 51820 table 51820

[#] ip -4 rule add table main suppress_prefixlength 0

[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1

sysctl: setting key "net.ipv4.conf.all.src_valid_mark": Read-only file system

[#] iptables-restore -n

iptables-restore: line 7 failed

[#] ip -4 rule delete table 51820

[#] ip -4 rule delete table main suppress_prefixlength 0

[#] ip link delete dev wg0

[cont-init.d] 99-custom-scripts: executing... 

[custom-init] no custom files found exiting...

[cont-init.d] 99-custom-scripts: exited 0.

[cont-init.d] done.

[services.d] starting services

[services.d] done.

When I launch the following command I get my residential IP (which indicates that I’m not connected to a VPN):

curl -w "\n" -s https://api.ipify.org

Do you have an idea of what I’m doing wrong?

Thanks!

your restore command is failing so i would assume none of your iptables rules are going into effect.

Thanks for the reply. Could this be related to me using this volume?

      - /lib/modules:/lib/modules

I’m on Windows 10. I’ve tried looking online, but I can’t find a way to load kernel linux modules when on Windows.

Unfortunately we dont test support or test our containers on windows, I believe you would first need to be using WSL2 then you would need to see how to install the modules into that. Then the container can use those modules.