Create a Linux VM and install Docker in it so you can (slowly) run x86 Docker containers on your Android device.
Recommended to use SSH or external keyboard to execute the following commands unless you want sore thumbs. See https://wiki.termux.com/wiki/Remote_Access#SSH
-
Install QEMU
pkg install qemu-utils qemu-common qemu-system-x86_64-headless
-
Download Alpine Linux 3.12 (virt optimized) ISO
mkdir alpine && cd $_ wget https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso
-
Create disk (note it won't actually take 64GB of space, more like 500MB)
qemu-img create -f qcow2 alpine.img 64G
-
Boot it up
qemu-system-x86_64 -machine q35 -m 2048 -smp cpus=4 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,hostfwd=tcp::2222-:22,hostfwd=tcp::2022-:22,hostfwd=tcp::9000-:9000 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.16.2-x86_64.iso -nographic alpine.img
If you have low cpu please change cpus=4
into cpus=2
and if you have high-end devices you can try with -smp 8,sockets=2,cores=2,threads=2,maxcpus=8
- Login with user
root
(no password)
-
Setup network (press Enter to use defaults):
setup-interfaces
Available interfaces are: eth0. Enter '?' for help on bridges, bonding and vlans. Which one do you want to initialize? (or '?' or 'done') [eth0] Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp] Do you want to do any manual network configuration? [no]
-
After setup network run command below to connect network:
ifup eth0
-
Create an answerfile to speed up installation:
wget https://gist.githubusercontent.com/Mhnramin/41ed38759c628a9ae941a7f59199d006/raw/84b37a68e0e8ec7775a8e88f8fa0464e7b2a3456/answerfile
-
Patch
setup-disk
to enable serial console output on bootsed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk
-
Run setup to install to disk
setup-alpine -f answerfile
-
Make a password for
root
login (press Enter to use defaults)Setup a user ? (enter a lower-case loginname, or 'no')[no]
-
Once installation is complete, power off the VM (command
poweroff
) and boot again without cdrom:qemu-system-x86_64 -machine q35 -m 2048 -smp cpus=4 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,hostfwd=tcp::2222-:22,hostfwd=tcp::2022-:22,hostfwd=tcp::9000-:9000 -device virtio-net,netdev=n1 -nographic alpine.img
make it same with first boot but without
-cdrom alpine-virt-3.16.2-x86_64.iso
just like above instruction -
Install docker and enable on boot:
alpine:~# apk update && apk add docker alpine:~# service docker start alpine:~# rc-update add docker
-
Useful keys:
- Ctrl+a x: quit emulation
- Ctrl+a h: toggle QEMU console
-
BIG THANKS TO:
#RUN-PONTAINER-DOCKER
If you wanna running pontainer from docker you have to run
and access pontainer from your browser with
http://your-ip-termux:9000