Docker kernel uniqueness

Philip Hutson
1 min readApr 29, 2022

TLDR: kernel calls in docker can report the real kernel version on the host.

A few months ago I was working on a project where I needed to compile some code that required the kernel source during the build process. To do that, during the build, it calls uname to determine which kernel version specific code to pull in. I was building the code in a CentOS docker container. The base container that I was starting from was an old CentOS 7 image. I went through the normal things and added the kernel source for the image using yum but it kept failing, telling me that it could not find the kernel source it needed. I was going round and round until I finally dug a bit more and realized that the version of the kernel source that was being pulled in via yum was not the version that uname was reporting when called in the build script. That’s when I found out that uname gets the kernel version from the kernel directly. Once I finally realized that the version of the kernel source that yum was pulling and the version being reported from uname was different I added a step in the docker file to patch the build script with a diff that can be easily changed as the targeted kernel version changes. After that it was back to finding all the correct dependencies and the correct versions.

--

--