Pcan adapter with docker container, set KERNEL_LOCATION variable to the root directory of your own built kernel

Run PCAN adapter from docker container of ubuntu 18.04.

The error is “Makefile:129 *** Unable to automatically find the kernel headers. These are mandatory to build the pcan driver. Please set the KERNEL_LOCATION variable to the root directory of your own built kernel.”

FROM amd64/python:3.7-slim-buster

WORKDIR /app

ADD cisco_umbrella_root_ca.crt /usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt

RUN chmod 644 /usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt && update-ca-certificates

RUN apt-get update

RUN apt-get install make -y

#RUN apt-get install linux-headers -y

RUN apt-get install -y --no-install-recommends software-properties-common

RUN apt-get -y install sudo

RUN sudo apt-get install -y --no-install-recommends gcc make python3-dev

#RUN pip install psutil --cert="/usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt"

#RUN pip3 install ptvsd==4.1.3 --cert="/usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt"

#COPY requirements.txt ./

#RUN pip3 install -r requirements.txt --cert="/usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt"

#RUN pip3 install j1939 --cert="/usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt"

#RUN pip3 install cantools --cert="/usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt"

#RUN pip3 install aio-timers --cert="/usr/local/share/ca-certificates/cisco_umbrella_root_ca.crt"

RUN pip install psutil

RUN pip3 install ptvsd==4.1.3

COPY requirements.txt ./

RUN pip3 install -r requirements.txt

RUN pip3 install j1939

RUN pip3 install cantools

RUN pip3 install aio-timers

#RUN apt-get install udev

#RUN apt-get install kmod

RUN mkdir -p /temp/peak-linux-driver-8.12.0

ADD peak-linux-driver-8.12.0 /temp/peak-linux-driver-8.12.0

WORKDIR /temp/peak-linux-driver-8.12.0/driver

RUN sudo make clean

#RUN make

RUN make install

RUN modprobe pcan

WORKDIR /app

COPY . .

CMD [ “python3”, “-u”, “./main.py” ]

There’s my dockerfile to run the peak adapter in a docker container running ubuntu 18.04.