Author Topic: 32bit Docker on Tiny Core Linux  (Read 426 times)

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3466
  • Developer
    • View Profile
    • PaulsCode.Com
32bit Docker on Tiny Core Linux
« on: May 21, 2017, 08:51:32 PM »
One of the system requirements listed for running Docker is a 64bit host.  I decided to conduct an experiment this weekend to see if I could build a 32bit version of Docker and have it run on 32bit Tiny Core Linux.  If it works, this could in theory be combined with an x86 emulator like QEMU to run docker containers from your Android phone..

The first step was to build a 32bit version of Docker Daemon and Docker Client.  I found a nice recipe for doing this HERE.  I had to tweak it a bit (require checking out tag 17.04.0-ce, and using this revision of the Dockerfile).

Then I installed Tiny Core Linux 8.0 x86 in Virtual Box, and after a lot of tinkering, came up with the following recipe to get the Docker Daemon to run without crashing:

Code: [Select]
tce-load -wi bash git procps xz ca-certificates iptables net-bridging-4.8.17-tinycore

sudo ln -s /usr/local/etc/ssl /etc/ssl

sudo addgroup docker
sudo addgroup tc docker

sudo mkdir /mnt/sda1/docker
sudo mkdir /mnt/sda1/docker/run
sudo mkdir /mnt/sda1/docker/lib
sudo chown -R root:docker /mnt/sda1/docker
sudo chmod -R 770 /mnt/sda1/docker
sudo ln -s /mnt/sda1/docker/run /var/run/docker
sudo ln -s /mnt/sda1/docker/lib /var/lib/docker

echo "etc/passwd" >> /opt/.filetool.lst
echo "etc/group" >> /opt/.filetool.lst
echo "etc/shadow" >> /opt/.filetool.lst
echo "etc/gshadow" >> /opt/.filetool.lst
echo "etc/profile.d" >> /opt/.filetool.lst
echo "etc/ssl" >> /opt/.filetool.lst
echo "etc/os-release" >> /opt/.filetool.lst
echo "var/lib/docker" >> /opt/.filetool.lst
echo "var/run/docker" >> /opt/.filetool.lst

echo "#!/bin/bash" >> /etc/profile.d/paths.sh
echo "export PATH=\$PATH:/home/tc/dockerd:/home/tc/docker" >> /etc/profile.d/paths.sh
chmod 755 /etc/profile.d/paths.sh

sudo touch /etc/os-release
sudo chown root:staff /etc/os-release
sudo chmod 664 /etc/os-release
echo "NAME=\"Tiny Core Linux\"" >> /etc/os-release
echo "ID=tinycore" >> /etc/os-release
echo "VERSION_ID=\"8.0\"" >> /etc/os-release
echo "PRETTY_NAME=\"Tiny Core Linux v8.0 x86\"" >> /etc/os-release
echo "HOME_URL=\"http://tinycorelinux.net/\"" >> /etc/os-release
echo "BUG_REPORT_URL=\"http://forum.tinycorelinux.net\"" >> /etc/os-release

cd ~
mkdir dockerd
mkdir docker

cd ~/dockerd
wget http://www.paulscode.com/downloads/dockerd.zip
unzip dockerd.zip

wget https://raw.githubusercontent.com/tianon/cgroupfs-mount/master/cgroupfs-mount
chmod 755 cgroupfs-mount

cd ~/docker
wget http://www.paulscode.com/downloads/docker.zip
unzip docker.zip

Then after a reboot:
Code: [Select]
sudo su
export DOCKER_RAMDISK=true
ulimit -Hn 65535
ulimit -Sn 65535
cgroupfs-mount
dockerd

However, when I ran a test of Docker Client, it failed with an error message about insufficient disk space.  This was related to a message from the Docker Daemon complaining that the kernel didn't support the "overlay" filesystem.  I ended up having to rebuild the Tiny Core kernel, setting flags "CONFIG_OVERLAY_FS" and "CONFIG_CFS_BANDWIDTH"
Code: [Select]
wget http://tinycorelinux.net/8.x/x86/release/src/kernel/linux-4.8.17-patched.txz
wget http://tinycorelinux.net/8.x/x86/release/src/kernel/config-4.8.17-tinycore
tar -xvf linux-4.8.17-patched.txz
cp config-4.8.17-tinycore linux-4.8.17/.config
cd linux-4.8.17

gedit .config
    CONFIG_OVERLAY_FS=y
    CONFIG_CFS_BANDWIDTH=y

make bzImage

Then I put the generated bzImage into the boot directory at /mnt/sda1/tce/boot, and and updated the bootloader:
Code: [Select]
DEFAULT bzim
LABEL core
KERNEL /tce/boot/vmlinuz
INITRD /tce/boot/core.gz
APPEND quiet  waitusb=5:UUID="fee3c2ac-3bf2-4aa1-ae8e-73fa95f4ea2c" tce=UUID="fee3c2ac-3bf2-4aa1-ae8e-73fa95f4ea2c"
LABEL bzim
KERNEL /tce/boot/bzImage
INITRD /tce/boot/core.gz
APPEND quiet  waitusb=5:UUID="fee3c2ac-3bf2-4aa1-ae8e-73fa95f4ea2c" tce=UUID="fee3c2ac-3bf2-4aa1-ae8e-73fa95f4ea2c"

Finally, after a reboot, I am able to successfully run Docker containers in 32bit  8)

« Last Edit: May 23, 2017, 10:43:58 PM by Paul »
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted