Skip to content

Instantly share code, notes, and snippets.

@dalehamel
Last active February 6, 2020 20:13
Show Gist options
  • Save dalehamel/43a6d96c63ef4adfd648c0862eb5a727 to your computer and use it in GitHub Desktop.
Save dalehamel/43a6d96c63ef4adfd648c0862eb5a727 to your computer and use it in GitHub Desktop.
install kernel headers for docker desktop, for BCC
#!/bin/bash
set -x
set -e
KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}"
kernel_version="$(echo "${KERNEL_VERSION}" | awk -vFS=- '{ print $1 }')"
major_version="$(echo "${KERNEL_VERSION}" | awk -vFS=. '{ print $1 }')"
apt-get install -y build-essential bc curl flex bison libelf-dev
mkdir -p /usr/src/linux
curl -sL "https://www.kernel.org/pub/linux/kernel/v${major_version}.x/linux-$kernel_version.tar.gz" | tar --strip-components=1 -xzf - -C /usr/src/linux
cd /usr/src/linux
zcat /proc/config.gz > .config
make ARCH=x86 oldconfig
make ARCH=x86 prepare
mkdir -p /lib/modules/$(uname -r)
ln -sf /usr/src/linux /lib/modules/$(uname -r)/source
ln -sf /usr/src/linux /lib/modules/$(uname -r)/build
@dalehamel
Copy link
Author

tested against latest docker stable (2.2.0) with kernel 4.19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment