Ubuntu内核启用cgroup CPU实时运行时遇阻,求CONFIG_RT_GROUP_SCHED配置方法
Hey there, I’ve run into this exact issue before—let’s walk through how to enable the missing CONFIG_RT_GROUP_SCHED kernel option so your Docker real-time setup works properly.
What You Need to Know
The CONFIG_RT_GROUP_SCHED option enables group scheduling for real-time processes (SCHED_FIFO/SCHED_RR), which is a hard requirement for Docker’s --cpu-rt-runtime flag to function. Since your RT kernel didn’t have this enabled by default, we’ll recompile the kernel with this option turned on.
Step 1: Prepare Kernel Source & Configuration
First, get your existing kernel setup ready:
- Ensure you have the 5.2.9-rt3 kernel source and RT patch applied (you likely already did this when building your initial RT kernel).
- Copy your current kernel config to the source directory (replace
~/linux-5.2.9with your actual kernel source path):cp /boot/config-$(uname -r) ~/linux-5.2.9/.config - Install dependencies for the kernel configuration interface:
sudo apt update && sudo apt install ncurses-dev build-essential libssl-dev bison flex
Step 2: Enable CONFIG_RT_GROUP_SCHED via Menuconfig
Launch the interactive kernel configuration menu:
cd ~/linux-5.2.9 make menuconfig
Navigate through the menu hierarchy to find the option:
General setup → Control Group support → Group scheduling for SCHED_FIFO/SCHED_RR
Use arrow keys to select this option, then press Y to compile it directly into the kernel (building it as a module with M isn’t recommended here—cgroup support needs this feature available at boot time).
Press ESC twice to exit, and save the configuration when prompted.
Step 3: Recompile & Install the Updated Kernel
Recompile the kernel (use -j$(nproc) to leverage all your CPU cores for faster builds):
make -j$(nproc)
Install the new kernel modules and kernel itself:
sudo make modules_install sudo make install
Update GRUB to recognize the modified kernel:
sudo update-grub
Reboot your system to load the updated RT kernel.
Step 4: Verify the Fix
After rebooting, run the Docker kernel compatibility script again—you should now see:
- CONFIG_RT_GROUP_SCHED: enabled
Try your original Docker run command once more, and it should execute without the "kernel does not support cgroup cpu real-time runtime" error.
Bonus: Use Ubuntu’s Deb-Pkg for Easier Management
If you prefer building a deb package (simpler to install/reinstall later), replace the compile/install steps with:
make deb-pkg -j$(nproc)
This generates .deb files in the parent directory. Install them with:
sudo dpkg -i ../linux-image-5.2.9-rt3_*.deb ../linux-headers-5.2.9-rt3_*.deb
Then update GRUB and reboot as before.
内容的提问来源于stack exchange,提问作者Baptiste BUSCH

