/Docker-CaraKernel-Termux

a repository to help you use docker in termux with the "CaraKernel" kernel

Primary LanguageShell

WARNING: THIS PROJECT HAS BEEN DISCONTINUED❌

Docker-CaraKernel-Termux

a repository to help you use Docker in Termux with the "CaraKernel" kernel

Requirements:

  • CaraKernel Support (I just tested it on device #Ginkgo)

  • Recovery (Recommended OrangeFox)

  • Module CaraKernel (necessary to work!)

  • Magisk/ROOT (v23+)

  • Some #Notes that are worth reading.


  1. First I rooted my Xiaomi Redmi Note 8. Then I installed PixelOS Android 13.
  2. Install Termux. Then execute Moby’s script to check kernel’s compatibility o running docker.

Before we proceed
Check kernel compatibility

 pkg in wget tsu -y
 wget https://raw.githubusercontent.com/moby/moby/master/contrib/check-config.sh
 chmod +x check-config.sh
 sed -i '1s_.*_#!/data/data/com.termux/files/usr/bin/bash_' check-config.sh
 sudo ./check-config.sh

  1. The missing configs will be displayed. Take notes of these red missing configs (especially configs under Generally Necessary), we have to enable them during kernel compliation.

Screenshot_Termux


This step would be the compilation of the kernel. but not necessarily if your kernel already has the parameters enabled (good luck)

  1. Before changing kernels, backup dtbo and boot
  2. Download CaraKernel (for ginkgo)
  3. Flash the ZIP to your #RECOVERY
  4. Flash the #MAGISK MANDATORY!

if it stays in bootloop, boot into recovery and restore the backup you made earlier.


It's show time...

Running Docker containers

A message “There is an internal problem with your device” will pop up on every boot. Just ignore it.

  1. Open Termux, mount cgroups:
sudo mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
  1. Enable binfmt_misc:
su
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
echo 1 > /proc/sys/fs/binfmt_misc/status
  1. Execute Moby’s script again: sudo ./check-config.sh. Make sure everything turns green.

Screenshot-Termux
Don't worry if it says: "CONFIG_PID_NS: missing, CONFIG_IPC_NS: missing, CONFIG_CGROUP_DEVICE: missing"


Install docker and docker-compose:

get docker /// Read here the reason that I put docker in another repository


Start docker daemon (Swipe from left edge of the screen and open a new session. Run containers)

 sudo dockerd --iptables=false

3.1.1. Internet access
The two network drivers tested so far are bridge and host. Here's how to get each of them working.

This is the default netwok driver. If you don't specify a driver, this is the type of network you are creating. Bridge networks isolate the container network by editing the iptables rules and creating a network interface called Docker0 that serves as a bridge. All containers created with the bridge driver will use this interface. This is analogous to creating a VLAN and running the containers inside it.

But, there's a catch in Android: iptables rules policy is different here than on a conventional GNU/Linux system (more info here). For the bridge driver to work, you'll have to manually edit the iptable by running;
 sudo ip route add default via 192.168.1.1 dev wlan0
 sudo ip rule add from all lookup main pref 30000

Note: change 192.168.1.1 according to your gateway IP.

Unfortunately, this means that changing networks will require you to re-configure the rules again.


Assuming you've done what you asked above, let's try creating an Ubuntu container

 sudo docker run -it ubuntu bash

The similar result will be: Screenshot_Termux


“Maybe you're wondering why the "apt update" command doesn't work”, yes, I let it go unnoticed, because I want to show you how to fix it:

sudo docker run -ti \
    --net="host" \
    --dns="8.8.8.8" \
    ubuntu

running this way, the apt command will work normally.
ps: Don't forget to remove the container we created earlier

So we can do this:

 sudo docker ps -a
 sudo docker rm <container_id>

something similar to this will be: Screenshot_Termux


Some important notes to read:

  • Attention, the current version Docker version v23.0.1, build of docker in termux doesn't work correctly. so i compiled Docker version v20.10.23-ce, build
  • Note: it is no longer necessary to use that version mentioned above. apparently they fixed the bugs that there were and now you can download directly from termux. the last version I just tested is v1:20.10.24-ce, build

  • this method was tested on Ginkgo using a PixelOS Android 13 custom rom.

  • don't ask me if it works for other types of kernels, I don't know.

  • the kernels I tested and not tested:

    • HoriKernel [work pass] (My Kernel)
    • CaraKernel Kernel [work pass]
    • Cryo Kernel [test fail]
    • ElasticsPerf Kernel [not booted]
    • Meow Kernel [test fail]
    • LightNing Kernel [test fail]
    • Ryzen Kernel [idk]
    • Syxteen Kernel [idk lol]
    • QuickSilve Kernel [idk, probably fail]

thanks to Freedie Oliveira for providing an efficient method and also docker-materia


if you think my work is cool or want to help me, make a small donation <3

send for btc address

 bc1qluadws0x8822urvhdufdeft4rs0ay290drlkpu