Wireguard - Kernel headers don't seem to be available, can't compile the module. Sleeping now

Hi all,

I am trying to get the Wireguard docker immage to work. It keeps failing with the message that the kernel headers don’t weem to be available.

I’m on a raspberry pi 4 running raspian lite. All the packages updated to the latest version.

The docker compose file that I run contains:

wireguard:
    image: linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1001
      - PGID=1001
      - TZ=Europe/Amsterdam
      - SERVERURL=[MYNAME].com #optional
      - SERVERPORT=51820 #optional
      - PEERS=2 #optional
      - PEERDNS=8.8.8.8 #optional
      - INTERNAL_SUBNET=10.0.0.0 #optional
    volumes:
      - /opt/wireguard/config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: unless-stopped

When I look at the logs I get:

wireguard | [s6-init] making user provided files available at /var/run/s6/etc…exited 0.
wireguard | [s6-init] ensuring user provided files have correct perms…exited 0.
wireguard | [fix-attrs.d] applying ownership & permissions fixes…
wireguard | [fix-attrs.d] done.
wireguard | [cont-init.d] executing container initialization scripts…
wireguard | [cont-init.d] 01-envfile: executing…
wireguard | [cont-init.d] 01-envfile: exited 0.
wireguard | [cont-init.d] 10-adduser: executing…
wireguard |
wireguard | -------------------------------------
wireguard | _ ()
wireguard | | | ___ _ __
wireguard | | | / | | | /
wireguard | | | _
\ | | | () |
wireguard | || |
/ || __/
wireguard |
wireguard |
wireguard | Brought to you by linuxserver.io
wireguard | -------------------------------------
wireguard |
wireguard | To support the app dev(s) visit:
wireguard | WireGuard: <link removed because I’m a new user>
wireguard |
wireguard | To support LSIO projects visit:
wireguard | <link removed because I’m a new user>
wireguard | -------------------------------------
wireguard | GID/UID
wireguard | -------------------------------------
wireguard |
wireguard | User uid: 1001
wireguard | User gid: 1001
wireguard | -------------------------------------
wireguard |
wireguard | [cont-init.d] 10-adduser: exited 0.
wireguard | [cont-init.d] 30-config: executing…
wireguard | Error: Unknown device type.
wireguard | **** The wireguard module is not active, will attempt kernel header install and module compilation. ****
wireguard | **** Attempting kernel header install ****
wireguard | Get:1 ports .ubuntu.com/ubuntu-ports bionic InRelease [242 kB]
wireguard | Get:2 ports .ubuntu.com/ubuntu-ports bionic-updates InRelease [88.7 kB]
wireguard | Get:3 ports .ubuntu.com/ubuntu-ports bionic-backports InRelease [74.6 kB]
wireguard | Get:4 ports .ubuntu.com/ubuntu-ports bionic-security InRelease [88.7 kB]
wireguard | Get:5 ports .ubuntu.com/ubuntu-ports bionic/restricted armhf Packages [12.5 kB]
wireguard | Get:6 ports .ubuntu.com/ubuntu-ports bionic/universe armhf Packages [11.0 MB]
wireguard | Get:7 ports .ubuntu.com/ubuntu-ports bionic/multiverse armhf Packages [157 kB]
wireguard | Get:8 ports .ubuntu.com/ubuntu-ports bionic/main armhf Packages [1,277 kB]
wireguard | Get:9 ports .ubuntu.com/ubuntu-ports bionic-updates/restricted armhf Packages [11.0 kB]
wireguard | Get:10 ports .ubuntu.com/ubuntu-ports bionic-updates/universe armhf Packages [1,171 kB]
wireguard | Get:11 ports .ubuntu.com/ubuntu-ports bionic-updates/main armhf Packages [834 kB]
wireguard | Get:12 ports .ubuntu.com/ubuntu-ports bionic-updates/multiverse armhf Packages [4,407 B]
wireguard | Get:13 ports .ubuntu.com/ubuntu-ports bionic-backports/main armhf Packages [8,247 B]
wireguard | Get:14 ports .ubuntu.com/ubuntu-ports bionic-backports/universe armhf Packages [8,101 B]
wireguard | Get:15 ports .ubuntu.com/ubuntu-ports bionic-security/multiverse armhf Packages [1,849 B]
wireguard | Get:16 ports .ubuntu.com/ubuntu-ports bionic-security/restricted armhf Packages [5,504 B]
wireguard | Get:17 ports .ubuntu.com/ubuntu-ports bionic-security/main armhf Packages [567 kB]
wireguard | Get:18 ports .ubuntu.com/ubuntu-ports bionic-security/universe armhf Packages [694 kB]
wireguard | Fetched 16.2 MB in 7s (2,342 kB/s)
wireguard | Reading package lists…
wireguard | **** Raspbian kernel naming convention detected, attempting to install raspbian kernel headers ****
wireguard | Warning: apt-key output should not be parsed (stdout is not a terminal)
wireguard | OK
wireguard | Hit:1 ports .ubuntu.com/ubuntu-ports bionic InRelease
wireguard | Hit:2 ports .ubuntu.com/ubuntu-ports bionic-updates InRelease
wireguard | Get:3 archive .raspberrypi.org/debian buster InRelease [32.6 kB]
wireguard | Hit:4 ports .ubuntu.com/ubuntu-ports bionic-backports InRelease
wireguard | Hit:5 ports .ubuntu.com/ubuntu-ports bionic-security InRelease
wireguard | Get:6 archive .raspberrypi.org/debian buster/main Sources [93.7 kB]
wireguard | Get:7 archive .raspberrypi.org/debian buster/main armhf Packages [330 kB]
wireguard | Fetched 457 kB in 2s (262 kB/s)
wireguard | Reading package lists…
wireguard | Reading package lists…
wireguard | Building dependency tree…
wireguard | Reading state information…
wireguard | The following NEW packages will be installed:
wireguard | raspberrypi-kernel-headers
wireguard | 0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
wireguard | Need to get 24.9 MB of archives.
wireguard | After this operation, 163 MB of additional disk space will be used.
wireguard | Get:1 archive .raspberrypi.org/debian buster/main armhf raspberrypi-kernel-headers armhf 1.20200601-1 [24.9 MB]
wireguard | Fetched 24.9 MB in 6s (4,080 kB/s)
wireguard | Selecting previously unselected package raspberrypi-kernel-headers.
(Reading database … 17288 files and directories currently installed.)
wireguard | Preparing to unpack …/raspberrypi-kernel-headers_1.20200601-1_armhf.deb …
wireguard | Unpacking raspberrypi-kernel-headers (1.20200601-1) …
wireguard | Setting up raspberrypi-kernel-headers (1.20200601-1) …
wireguard | run-parts: executing /etc/kernel/header_postinst.d/dkms 4.19.118+
wireguard | * dkms: running auto installation service for kernel 4.[ OK ]
wireguard | run-parts: executing /etc/kernel/header_postinst.d/dkms 4.19.118-v7+
wireguard | * dkms: running auto installation service for kernel 4.[ OK ] v7+
wireguard | run-parts: executing /etc/kernel/header_postinst.d/dkms 4.19.118-v7l+
wireguard | * dkms: running auto installation service for kernel 4.[ OK ] v7l+
wireguard | run-parts: executing /etc/kernel/header_postinst.d/dkms 4.19.118-v8+
wireguard | * dkms: running auto installation service for kernel 4.[ OK ] v8+
wireguard | **** Kernel headers don’t seem to be available, can’t compile the module. Sleeping now. . . ****

I’m at a loss. I tried to google for the error messages, but did not get any relevant results. Does anyone have an idea on how to solve this?

Thanks,

Mark

What’s the raspbian version and what’s the kernel?

Raspian version 10 (buster)
uname -a gives:
Linux raspberrypi4 5.4.49-v7l+ #1323 SMP Fri Jun 26 14:40:18 BST 2020 armv7l GNU/Linux
mark@raspberrypi4

You’re using a beta kernel, so you’ll have to install the kernel headers on the host and map /usr/src

Strange, I am not knowingly using a beta kernel. Anyway, I added - /usr/scr:/usr/scr to my docker compose file under volumes. Result is still the same.

You need to install the kernel headers on host

Sorry, didn’t mention that. I did. I did sudo apt-get install raspberrypi-kernel-headers on the host, but no luck

Just now some upgrades to kernel and kernel-headers became available. Aftter upgrading the host, rebooting and restarting the docker container. Everything seems to work perfectly. Thanks to all for the hard work.

1 Like

Hi can you please describe more how did you solved this? I’m having same problem and can find the solution. Thanks a lot

Can’t really add anything to my previous posts. I updated using apt-get update and apt-get upgrade and then wireguard started to work. It was a couple of days later.

Okay thank you for quick reply. Will keep on trying. Thx

Just tried to set this up fresh on a Raspberry Pi 4 (Raspbian Buster) and same result.
Tried:

  • docker-compose up = resulted in …sleeping
  • sudo apt update && sudo apt upgrade && sudo apt install raspberrypi-kernel-headers on the host, then re-up the docker compose container = resulted in …sleeping
  • after above step, mapped /usr/src in compose config and re-up container = still resulted in …sleeping

All with latest image for wireguard and kernel: 5.4.79-v7l+ #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux