How to compile C code that is using kernel function in docker and use pci device in container? How to compile C code that is using kernel function in docker and use pci device in container? docker docker

How to compile C code that is using kernel function in docker and use pci device in container?


If your app can compile with any generic linux headers

In your Dockerfile change

RUN apt-get install -y linux-headers-$(uname -r)

to just

RUN apt-get install -y linux-headers-generic 

or if you need the same specific one as your host systemwhy dont you just volume link this directory from host to the docker container with the -v?

on your host system:

sudo apt-get install linux-headers-$(uname -r)

Now you have the kernel headers here: /usr/src/linux-headers-$(uname -r)/include

now on your docker container run command, link that volume like

-v /usr/src/linux-headers-$(uname -r)/include:/usr/src/linux-headers-$(uname -r)/include