It is possibe to run docker containers on Android phone with a custom kernel which enable cgroups and other missing features.
- My deivce: Xiaomi Redmi Note 5 (whyred)
- Phone OS: Lineage OS 18 (Android 11). Rooted.
You can download my pre-compiled kernel here if you own the device: https://github.com/ivon852/android_kernel_xiaomi_whyred_docker
1. Check if the device supports docker features
- The device must be rooted. Install Termux and check if your device supports docker:
- You will see many red “missing”" under “Generally Necessary”. So we must enable them in the following steps.
2. Download and modify the kernel
Xiaomi phone is easy for flashing custom roms. Also there are many third-party kernel for them. Sometimes the code is more reliable than the official ones.
So I choose RAD kernel to begin with.
My computer operating system is Lubuntu 20.04. You may need a Linux VM for compiling the kernel on Windows.
Now, please wathc fossfrog’s guide to learn how to compile a custom kernel:
3. Enable missing features in kernel
make menuconfigto launch kconfig Enable all missing features in kernel.
For exaple, to enable
/in main menu.
Inout the config name, it will tell your where it is.
Use up and down arrow key to move. Press
yto enable it.
Then, use right and left key to move to
Save. Then move to
According to FreddieOliveira’s instructions, you also need to modify
- And this
- Complile the kernel
Repackage the kerenel into boot.img with Android Image Kitchen. Flash boot.img to the phone.
For Redmi Note 5, run this command after boot:
4. Install docker in Termux
- Run Moby’s script again to check if all “Generally Necessary” items are green. Then install docker packages:
- Start second Termux session (swipe from left). Start docker daemon。
- Open a new sesson. Pull image
hello-world. You shall see a welcome message by docker.
- Now try runngni a Apache container:
- Now docker is running on your Android phone.
This tutorial shows how to run docker natively on Android, without VMs and chroot.