Skip to content

About

A VM manager like Lima/Colima but for Docker in WASM (unkernel) in Termux in Android! No root or kvm needed.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

unkernel-docker

Run Docker in Termux (without root or QEMU) inside an isolated Debian VM powered by unkernel.

docker-vm.mjs manages a background VM, persists Docker images and packages on a sparse ext4 disk image in ~/.unkernel-docker, mounts your $HOME directory at the same path inside the VM, exposes the Docker daemon over both a Unix socket and TCP, and automatically forwards container/guest ports to 127.0.0.1 on the host.

This is similar to https://github.com/luisdavim/termux-qemu-docker but using unkernel instead of QEMU. The idea is to provide a similar UX to lima and colima but with support for Android Termux.

Features

  • No QEMU required: Boots a Debian VM via WebAssembly (unkernel).
  • Persistent storage: Stores /var/lib/docker and installed runtime packages on a sparse ext4 disk image (~/.unkernel-docker/docker-data.img, 16 GB by default).
  • Consistent path mapping: Mounts $HOME at the exact same path inside the VM so bind mounts and docker commands work seamlessly from your working directory.
  • Automatic port forwarding: Discovers container PortBindings and guest listening TCP ports (>= 1024) and forwards them to 127.0.0.1 on Termux.
  • Transparent -p support: Proxies both the Unix socket and TCP API, rewriting default/bridge NetworkMode to host on container creation so -p HOST:CONTAINER works even from the native Termux docker CLI.
  • Interactive shell & wrapper: Run exec for a shell in the VM or docker to run commands without needing a local docker client.

Prerequisites

  • Node.js >= 24 (required by unkernel)
  • e2fsprogs (for mkfs.ext4 and e2fsck)

On Termux:

pkg install -y nodejs e2fsprogs

Install npm dependencies in this repository:

npm install

Quick Start

Start the VM in the background:

node ./docker-vm.mjs start

Note: The first boot is expected to be slower (a few minutes) because it downloads the Debian image (cached in ~/.cache/unkernel), formats and checks the sparse disk image, and installs Docker and socat inside the VM. Subsequent boots start Docker from the persisted package state.

Once healthy, connect your native docker CLI using either the Unix socket or TCP:

export DOCKER_HOST=unix://${HOME}/.unkernel-docker/docker.sock

or:

export DOCKER_HOST=tcp://localhost:2375

Then run Docker as usual:

docker run --rm hello-world
docker run --name some-nginx -it --rm -p 8080:80 nginx

Exposed ports (>= 1024) are automatically forwarded to 127.0.0.1:<port> on the host (e.g. http://127.0.0.1:8080).

Commands

Command Description
node ./docker-vm.mjs start [options] Start the VM daemon in the background and wait until healthy
node ./docker-vm.mjs status Show VM status, stage, PID, and forwarded ports as JSON
node ./docker-vm.mjs exec Open an interactive root shell inside the VM
node ./docker-vm.mjs exec <cmd...> Run a command inside the VM
node ./docker-vm.mjs docker <args...> Run docker inside the VM (passes TTY, stdin, and $HOME-relative cwd)
node ./docker-vm.mjs stop Gracefully stop Docker, unmount the data disk, and shut down the VM
node ./docker-vm.mjs delete [-f] Stop the VM if running and delete all state in ~/.unkernel-docker

start accepts --cpus <count> to set guest CPUs (default: 4), --memory <MiB> to set guest memory (default: 4096 MiB), and --disk <GB> to set the persistent disk size (default: 16 GB). For example:

node ./docker-vm.mjs start --cpus 2 --memory 4096 --disk 32

The disk can be grown but not shrunk. Stop an already running VM before restarting it with different resource limits or disk size.

Examples

Open a shell in the VM:

node ./docker-vm.mjs exec

Run a command in the VM:

node ./docker-vm.mjs exec uname -a

Run docker via the built-in wrapper (useful if you don't have the docker CLI installed on Termux):

node ./docker-vm.mjs docker run --name some-nginx -it --rm -p 8080:80 nginx

Remove the VM and all persisted Docker data (skip prompt with -f / --force):

node ./docker-vm.mjs delete

State & Logs

All VM state lives in ~/.unkernel-docker/:

  • docker-data.img — sparse ext4 persistent disk (16 GB by default)
  • docker.sock — Host-side Docker Unix socket (owner-only permissions)
  • ctl.sock — Control socket for CLI commands
  • vm.pid — Background daemon PID
  • vm.log — Daemon and boot logs (check here if startup fails)

The ext4 disk holds Docker data, /usr, /etc, and apt/dpkg state. Docker's runtime socket is recreated on each boot, and the filesystem is checked before mounting.

About

A VM manager like Lima/Colima but for Docker in WASM (unkernel) in Termux in Android! No root or kvm needed.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages