pkg update && pkg upgrade
pkg install openssh
whoami
passwd
ifconfig
sshd
- Install qemu and wget
Open a new terminal on your PC and ssh (I prefer ssh, much easier than typing on your phone) to your android smartphone and make sure your PC and phone are connected on the same network or wifi.
It depends on your phone, in my case u03_a373 is what I got from running whoami
and 192.168.254.102 from ifconfig
in step 2.
ssh-copy-id -p 8022 -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes u0_a373@192.168.254.102
ssh u0_a373@192.168.254.102 -p 8022
Install packages.
pkg install qemu-system-x86-64-headless qemu-utils
pkg install wget
- Download the latest alpine virtual image
wget https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso
- Create qemu image and run the installer
qemu-img create -f qcow2 alpine.qcow2 10G
qemu-system-x86_64 -smp 2 -m 2048 \
-drive file=alpine.qcow2,if=virtio \
-netdev user,id=n1,hostfwd=tcp::2222-:22,hostfwd=tcp::2375-:2375 \
-device virtio-net,netdev=n1 \
-cdrom alpine-virt-3.19.1-x86_64.iso -boot d \
-nographic
Once prompted, login a root user and run the following to fix dns resolution.
mkdir -p /etc/udhcpc
echo 'RESOLV_CONF="no"' >> /etc/udhcpc/udhcpc.conf
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" >> /etc/resolv.conf
Run the installation.
setup-alpine
Just take the defaults. Set the root password and Timezone according to your location. When ask to allow root login, enter yes.
When asked whch disk to use, select 10GB disk that was created in qemu-img. How would you like to to use it, enter sys.
Erase disk and run poweroff
after installation.
- Start qemu without the cdrom
qemu-system-x86_64 -smp 2 -m 1024 \
-drive file=alpine.qcow2,if=virtio \
-netdev user,id=n1,hostfwd=tcp::2222-:22,hostfwd=tcp::2375-:2375 \
-device virtio-net,netdev=n1 \
-daemonize
- Ssh to the virtual image and install docker
ssh-keygen -t ed25519
ssh-copy-id -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes root@localhost -p 2222
ssh root@localhost -p 2222
Install docker and docker-compose.
apk add vim
vi /etc/apk/repositories (uncomment community repository)
apk update
apk upgrade
apk add docker
service docker start
rc-update add docker boot
vi /etc/conf.d/docker (update DOCKER_OPTS to DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --iptables=false")
rc-update add docker boot
service docker restart
- Install docker and docker-compose in termux
pkg install root-repo
pkg install docker docker-compose
docker version
export DOCKER_HOST=localhost:2375
docker run hello-world
- Append to $HOME/.bashrc
checkssh=$(ps -ef | grep "[s]shd" | wc -l)
if [ $checkssh -ne 2 ]; then
eval $(sshd)
fi
checkqemu=$(ps -ef | grep "[q]emu" | wc -l)
if [ $checkqemu -eq 0 ]; then
eval $(qemu-system-x86_64 -smp 2 -m 1024 -drive file=alpine.qcow2,if=virtio -netdev user,id=n1,hostfwd=tcp::2222-:22,hostfwd=tcp::2375-:2375 -device virtio-net,netdev=n1 -daemonize)
fi
export DOCKER_HOST=localhost:2375
For resizing qemu qcow2 image
qemu-img resize alpine.qcow2 100G