Skip to content

Instantly share code, notes, and snippets.

@itisFarzin
Last active March 24, 2025 09:26
Show Gist options
  • Save itisFarzin/7b999b2231ceb943a0bc40733551a7a5 to your computer and use it in GitHub Desktop.
Save itisFarzin/7b999b2231ceb943a0bc40733551a7a5 to your computer and use it in GitHub Desktop.
Docker On Ubuntu Touch

Docker On Ubuntu Touch

How did we get here?

I like to give a purpose to the phones that I don't use actively, so let's run Docker on one of them. My experience with running Docker on Ubuntu Touch was a bit rough. I compiled the kernel with the "required" configurations for Docker and lost Wi-Fi. After a couple of days (sigh), I remembered that our kernel uses modules for certain drivers, and one of them was for WLAN. After I generated my own rootfs and flashed it, Wi-Fi started working again. After installing the apt version of Docker (I'll say why I chose the apt version later), I got Docker to work—yay!

The reason for not going with the Snap version of Docker was that it couldn't even run the hello-world container. No matter what I tried, I had no luck, so I gave up on it for now. I'll try to get the Snap version to work because with a UT update, I'll lose my Docker.

The juicy part

Setting up the build system

Clone your device port from here. Since my device is "volla algiz" (It's not really), I cloned this repo.

With the code below (which comes from this file), I got boot and rootfs to build, you may need to adapt it for you own device.

git clone https://gitlab.com/ubports/porting/reference-device-ports/halium13/volla-phone-quintus/volla-algiz
cd volla-algiz
git clone -b main https://gitlab.com/ubports/porting/community-ports/halium-generic-adaptation-build-tools.git build
DEVICE="$(source deviceinfo && echo $deviceinfo_codename)"
./build.sh -b ~/ubports/volla-algiz-builds/
./build/prepare-fake-ota.sh out/device_${DEVICE}.tar.xz ota
mkdir -p out
./build/system-image-from-ota.sh ota/ubuntu_command out
mv out/rootfs.img out/ubuntu.img

Note: I used the -b flag for build.sh to avoid downloading dependencies every time.

In the same directory, flash out/boot.img and out/ubuntu.img to your phone, hopefully it will boot and you're good to continue.

Needed kernel changes

Run this script on your device to see which configurations are missing. To enable missing configurations, you can manually add them to arch/arm64/configs/halium.config (for arm64 devices—this path should be the same in your kernel tree). However, I wouldn’t recommend doing this directly, as some configurations might depend on others that aren’t enabled. To check dependencies, use make menuconfig. Follow the steps below, making sure to change the defconfig file name to match your device’s:

export ARCH=arm64
export SUBARCH=arm64

make k6877v1_64_k419_defconfig halium.config
make menuconfig

In the menu, press the slash (/) key on your keyboard, type or paste the name of the missing configuration, and check the "Depends on" section. If there are dependencies, check their missing configurations as well and add them to arch/arm64/configs/halium.config in the following format:

CONFIG_OPTION=y

Now the missing configuration should be enabled and do this for every missing configurations. Now, re-run the code for generating boot and rootfs, flash them and check if the configurations you enabled are actually enabled or not.

Additionally, you may need to apply patches to your kernel tree, depending on your kernel version. These patches can be found here, and the reasoning behind applying them is explained here.

Install Docker

If you want to use Docker, you must keep the root filesystem mounted as read-write.

sudo mount -o remount,rw /

Next, install Docker via apt:

sudo apt update
sudo apt install docker.io

And now, run the hello-world container:

sudo docker run hello-world

If you see the "Hello from Docker!" message, congratulations—you’ve done it!

Set up Docker

Since Docker is running on the root partition, you'll run out of storage quickly.

To prevent this, move Docker’s root directory to your home directory by running the following command:

rm -f /etc/docker/daemon.json
sudo tee /etc/docker/daemon.json > /dev/null << 'EOF'
{
    "data-root": "/home/phablet/docker-data/lib/docker",
    "exec-root": "/home/phablet/docker-data/run/docker",
    "pidfile": "/home/phablet/docker-data/run/docker.pid",
    "hosts": [
        "unix:///home/phablet/docker-data/run/docker.sock"
    ],
    "storage-driver": "vfs"
}
EOF

After that, add these lines to .bashrc file:

export DOCKER_HOST="unix:///home/phablet/docker-data/run/docker.sock"
alias docker="sudo -E docker"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment