A lightweight, profile-aware container VM manager for Termux. termux-qemu-docker automates the complex setup required to run Docker containers on Android without root, by spawning an isolated Alpine Linux VM via QEMU and exposing the Docker daemon via a file socket to your Termux environment.
The idea is to provide a similar UX to lima and colima but for Android Termux.
- Automated Setup: One-command dependency installation and configuration.
- Automatic port forwarding: Detect open ports on the Docker VM and automatically setup port-forwarding
- True Docker Support: Run real Docker containers within a lightweight Alpine VM.
- Profile Aware: Create multiple isolated VM instances (e.g.,
dev,prod,test) with unique network ports. - Cloud-Init Integration: Automatic root password and SSH configuration on first boot.
- Folder Sync: High-performance host directory sharing via Virtio-9p.
- docker and docker-compose wrapper: Run
dockeranddocker-composecommands directly on the VM
Before starting, ensure you have a modern Android device with Termux installed. The tool will automatically attempt to install the following via pkg:
qemu-system-aarch64-headless(orx86_64)qemu-utilsopensshlibisoburn(xorrisofs)dosfstools
-
Build the binary:
go build -o termux-qemu-docker main.go
-
Run the automated setup: This installs dependencies and generates a default
config.yaml.termux-qemu-docker setup
-
Start the VM:
termux-qemu-docker start
Once the VM is "Healthy", termux-qemu-docker will provide an export command. To connect your Termux docker CLI to the VM's daemon, run:
export DOCKER_HOST=unix://${HOME}/.termux-qemu-docker/docker-default.sockYou can now use docker as if it were native:
docker run --rm hello-world
docker psAlternatively, if you don't have the docker client installed on your device, you can run docker and docker-compose commands directly on the VM.
termux-qemu-docker docker run --name some-nginx -i --rm -p 8080:80 nginxThe ports exposed by the containers will still be available on the host device though the automatic port-forwarding.
By default, the tool maps your entire $HOME directory to the same path inside the VM using Virtio-9p. This enables Consistent Path Mapping: a file at /data/data/com.termux/files/home/project/main.go in Termux is accessible at the exact same path inside the VM.
This allows you to edit code in Termux (using Neovim, Micro, etc.) and run it inside a Docker container with near-native performance and no path-mapping confusion.
You can configure multiple shared folders in your profile's config.yaml:
mounts:
- /data/data/com.termux/files/home
- /sdcard/DocumentsThe tool also automatically attempts to mount the Termux $PREFIX/tmp directory if it exists.
Create separate environments using the -p or --profile flag:
termux-qemu-docker -p web-dev start
termux-qemu-docker -p database start
termux-qemu-docker listEach profile gets its own disk image and unique SSH port.
You can override resources during start, and they will be saved to your profile's config:
termux-qemu-docker start --cpus 4 --memory 4096 --disk 20To gracefully shut down the VM:
termux-qemu-docker stop
# Or for a specific profile
termux-qemu-docker -p web-dev stopTo completely remove a profile and its disk image:
termux-qemu-docker delete
# Or for a specific profile
termux-qemu-docker -p web-dev delete- Isolation: Containers run inside a dedicated VM, providing a layer of security between Docker and your Android OS.
- Encapsulation: Remote commands use escaped shell arguments to prevent injection.
- Lifecycle: Resource allocation and port listeners are context-bound and shut down automatically with the VM.