How can i make the linux container to use linux Kernel Version
Since host has this version
cat /proc/version
Linux version 6.2.0-20-generic`
but
sudo kvm-ok
INFO: /dev/kvm does not exist
HINT: sudo modprobe kvm_intel
modprobe: FATAL: Module msr not found in directory /lib/modules/6.2.0-20-generic
does not pick up the kernel for some reason. if i check the folders in /lib/modules its an old version of 5.15.x
A container automatically uses the host’s kernel (try running uname -a from inside the container to confirm this).
That doesn’t mean you’ll be able to load kernel modules etc from inside the container. That would be a huge security breach - you’d be loading the modules on the host.
as @RichardHuxton pointed, containers use the same kernel as the host does. And you can’t load kernel modules from inside the container (unless your container is privileged). If you have another kernel version in /lib/modules/... inside the container it just doesn’t mean that your container use another kernel version.
If you want to use KVM acceleration inside the container I can suggest you to to modprobe kvm from the host in advance, allow /dev/kvm inside the container (using lxc.cgroup2.devices.allow = ...), create /dev/kvm device node inside the container (you will need to enable mknod interception too).
Upd. I wasn’t right about mknod interception, it’s limited to a few character devices and /dev/kvm not in the list.