jessfraz / dockerfiles

Various Dockerfiles I use on the desktop and on servers.
https://blog.jessfraz.com/post/docker-containers-on-the-desktop/
MIT License
13.66k stars 2.55k forks source link

Wireguard docker image doesn't work on CENTOS 7 #454

Open abcdef123ghi opened 5 years ago

abcdef123ghi commented 5 years ago

I deployed a VPS on Vultr,Although I have upgraded the kernel within the Centos 7 from 3.10 to 4.20,and I have change the parameter which is modules location and header location,it just doesn't work in Cent OS 7 ,the header files is located in /usr/include and the modules files is in /lib/modules/4.20.2-1.el7.elrepo.x86_64 then I inputed the command which was

docker run --rm -it \ --name wireguard \ -v /etc/wireguard:/etc/wireguard \ -v /lib/modules/4.20.2-1.el7.elrepo.x86_64:/lib/modules \ -v /usr/include:/usr/src:ro \ r.j3ss.co/wireguard:install

Unable to find image 'r.j3ss.co/wireguard:install' locally install: Pulling from wireguard cd784148e348: Pull complete 74376a61d579: Pull complete dd348312c1df: Pull complete bc712e2ba41a: Pull complete Digest: sha256:375417a542a244537a92b60a9053ec5722c507dc38616b8f01c4e8333c56efa1 Status: Downloaded newer image for r.j3ss.co/wireguard:install Building the wireguard kernel module... make[1]: /lib/modules/4.20.2-1.el7.elrepo.x86_64/build: No such file or directory. Stop. make: [Makefile:36: module] Error 2

any idea?what wrong I have done?thank you very much

tuxfanou commented 5 years ago

The error is beacause Make can't load kernel module. You need to install kernel-devel and/or kernel-headers.

But, maybe you can't do it if your VPS is an LXC machine. In this case, you need to ask installation of kernel modules to your provider.

abcdef123ghi commented 5 years ago

The error is beacause Make can't load kernel module. You need to install kernel-devel and/or kernel-headers.

But, maybe you can't do it if your VPS is an LXC machine. In this case, you need to ask installation of kernel modules to your provider.

thanks for replying ,I have installed the kernel-devel and/or kernel-headers though take a look at this

rpm -qa | grep kernel

kernel-tools-libs-3.10.0-957.1.3.el7.x86_64 kernel-ml-devel-4.20.2-1.el7.elrepo.x86_64 kernel-ml-4.20.2-1.el7.elrepo.x86_64 kernel-tools-3.10.0-957.1.3.el7.x86_64 kernel-3.10.0-862.el7.x86_64 kernel-3.10.0-957.1.3.el7.x86_64 kernel-3.10.0-862.14.4.el7.x86_64 kernel-headers-3.10.0-957.1.3.el7.x86_64

btw my VPS is a KVM machine

tuxfanou commented 5 years ago

You have linux-devel for 4.20 and linux headers for 3.10 In the error, you need 4.20.2-1.el7.elrepo.x86_64

With uname -a you have the kernel version currently used. You need packages for this version.

abcdef123ghi commented 5 years ago

uname -a

thanks for replying the current kernel version is 4.20 uname -a Linux 4.20.2-1.el7.elrepo.x86_64 #1 SMP Sun Jan 13 09:57:55 EST 2019 x86_64 x86_64 x86_64 GNU/Linux

abcdef123ghi commented 5 years ago

I tried another way,but it doesn't work as well, I deleted all the datas in VPS,and reinstall a new Centos 7 and I downloaded the lastest stable kernel source code 4.20 and extracted it to the source directory which is /usr/src,then I builded it.the kernel and modoules were sucessfully builded , however the wireguard docker image doesn't work

$ docker run --rm -it \ --name wireguard \ -v /etc/wireguard:/etc/wireguard \ -v /lib/modules:/lib/modules \ -v /usr/src:/usr/src:ro \ r.j3ss.co/wireguard:install Unable to find image 'r.j3ss.co/wireguard:install' locally install: Pulling from wireguard cd784148e348: Pull complete 74376a61d579: Pull complete dd348312c1df: Pull complete bc712e2ba41a: Pull complete Digest: sha256:375417a542a244537a92b60a9053ec5722c507dc38616b8f01c4e8333c56efa1 Status: Downloaded newer image for r.j3ss.co/wireguard:install Building the wireguard kernel module... CC [M] /wireguard/src/main.o /bin/sh: scripts/basic/fixdep: not found make[2]: [scripts/Makefile.build:292: /wireguard/src/main.o] Error 127 make[1]: [Makefile:1563: module/wireguard/src] Error 2 make: *** [Makefile:36: module] Error 2

$uname -r 4.20.3

abcdef123ghi commented 5 years ago

your docker image is competely not working! I have tried it on a Ubuntu 16.04, it doesn't work as well!

$ sudo docker run --rm -it \ --name wireguard \ -v /etc/wireguard:/etc/wireguard \ -v /lib/modules:/lib/modules \ -v /usr/src:/usr/src:ro \ r.j3ss.co/wireguard:install Unable to find image 'r.j3ss.co/wireguard:install' locally install: Pulling from wireguard cd784148e348: Pull complete 74376a61d579: Pull complete dd348312c1df: Pull complete bc712e2ba41a: Pull complete Digest: sha256:375417a542a244537a92b60a9053ec5722c507dc38616b8f01c4e8333c56efa1 Status: Downloaded newer image for r.j3ss.co/wireguard:install Building the wireguard kernel module... arch/x86/Makefile:133: stack-protector enabled but compiler support broken Makefile:670: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler CC [M] /wireguard/src/main.o /wireguard/src/main.c:1:0: error: code model kernel does not support PIC mode // SPDX-License-Identifier: GPL-2.0

make[2]: [scripts/Makefile.build:259: /wireguard/src/main.o] Error 1 make[1]: [Makefile:1396: module/wireguard/src] Error 2 make: *** [Makefile:36: module] Error 2