Skip to content

Instantly share code, notes, and snippets.

@whokilleddb
Last active August 7, 2025 04:30
Show Gist options
  • Select an option

  • Save whokilleddb/aea5b8bd44a5f815ed70f29c13ea88c6 to your computer and use it in GitHub Desktop.

Select an option

Save whokilleddb/aea5b8bd44a5f815ed70f29c13ea88c6 to your computer and use it in GitHub Desktop.
Dockerfile to compile Linux Kernel from source
FROM debian:10.11 as source
WORKDIR /kernel
# Extra Metadata
LABEL version = "0.1.0"
LABEL desciption = "Compile A Kernel"
# Install Dependencies
FROM source as init
RUN apt update -y && apt upgrade -y
RUN apt install -y apt-utils
RUN apt install -y build-essential
RUN apt install -y gcc
RUN apt install -y libncurses-dev
RUN apt install -y gawk
RUN apt install -y flex
RUN apt install -y bison
RUN apt install -y openssl
RUN apt install -y libssl-dev
RUN apt install -y dkms
RUN apt install -y libelf-dev
RUN apt install -y libudev-dev
RUN apt install -y libpci-dev
RUN apt install -y libiberty-dev
RUN apt install -y autoconf
RUN apt install -y git
RUN apt install -y wget
# Fetch Kernel Sources
FROM init as fetch
RUN wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.11.tar.xz
RUN wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.11.tar.sign
# Verify Downloads
FROM fetch as verify
RUN gpg --list-packets linux-5.15.11.tar.sign
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys $(gpg --list-packets linux-5.15.11.tar.sign | grep issuer | xargs | cut -d ' ' -f9 | sed -s 's/)//g')
RUN unxz linux-5.15.11.tar.xz
RUN gpg --verify linux-5.15.11.tar.sign
# Build Kernel
FROM verify as compile
RUN tar -xvf linux-5.15.11.tar
RUN cd linux-5.15.11 && make mrproper
FROM compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment