-
-
Save reski-rukmantiyo/64207f86e649d66a9b5d13dea639401b to your computer and use it in GitHub Desktop.
Install Docker on Termux
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 http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.3-x86_64.iso
-
Create disk (note it won't actually take 100GB of space)
qemu-img create -f qcow2 alpine.img 100G
-
Boot it up
qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 \ -drive file=alpine.img,if=virtio \ -netdev user,id=n1,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 \ -cdrom alpine-virt-3.12.3-x86_64.iso \ -nographic alpine.img
-
Login with user
root
(no password) -
Setup network (press Enter to use defaults):
localhost:~# 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] localhost:~# ifup eth0
-
Patch
setup-disk
to enable serial console output on bootlocalhost:~# sed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk
-
Run setup to install to disk
localhost:~# setup-alpine -f answerfile
-
Once installation is complete, power off the VM (command
poweroff
) and boot again without cdrom:qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 \ -drive file=alpine.img,if=virtio \ -netdev user,id=n1,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 \ -nographic alpine.img
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KEYMAPOPTS="us us" | |
HOSTNAMEOPTS="-n alpine-docker" | |
INTERFACESOPTS="auto lo | |
iface lo inet loopback | |
auto eth0 | |
iface eth0 inet dhcp | |
hostname alpine | |
" | |
TIMEZONEOPTS="-z Asia/Jakarta" | |
PROXYOPTS="none" | |
APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v3.12/main http://dl-cdn.alpinelinux.org/alpine/v3.12/community" | |
SSHDOPTS="-c openssh" | |
NTPOPTS="-c busybox" | |
DISKOPTS="-v -m sys -s 0 /dev/vda" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modified to use virtio...Wuzz