uname returns host-kernel in Docker container

Solution 1:

It's reasonable to expect that the Docker container would be running a different kernel if you are thinking about Docker as some sort of "virtual machine" technology, which it really isn't.

The "container" part of Docker is that it is being created within the Linux host instance. That's what gives it its millisecond startup time. Docker (and other similar technologies) are built using existing kernel features such as LXC, chroot, cgroups, and others.

If your Docker host was a "real" Linux instance, the container would also always show the same kernel as the host's with a uname -r.

Search for something like docker chroot or docker lxc for more information on the internals.

And yet there's still virtualization going on with WSL. Before WSL (and still as an alternative), Docker on Windows did use a Virtual Machine for the Linux instance. Then the container ran inside that VM, using its kernel and sharing its resources. But now, with WSL2, its kernel can be utilized. Yes, still behind the scenes it's a Hyper-V VM (of sorts) that's running WSL2, but it's so much more streamlined and integrated with the Windows host now.