Git Product home page Git Product logo

docker-in-termux's Introduction

Installing Docker in Termux

This repository contains instructions on how to install Docker in Termux, a powerful terminal emulator for Android.

Prerequisites

Before proceeding with the installation, make sure you have the following prerequisites:

  • An Android device with Termux installed. You can download Termux from the F-Droid app store.
  • Stable internet connection.

Installation Steps

Follow the steps below to install Docker in Termux:

  1. Open Termux on your Android device.

  2. Update and upgrade the packages by running the following command:

pkg update -y && pkg upgrade -y
  1. Install the necessary dependencies by running the following command:
pkg install qemu-utils qemu-common qemu-system-x86_64-headless wget -y
  1. Create a seperate directory:
mkdir alpine && cd alpine
  1. Download Alpine Linux 3.19 (virt optimized) ISO:
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso
  1. Create disk (note it won't actually take 5GB of space, more like 500-600MB):
qemu-img create -f qcow2 alpine.img 5G
  1. Boot it up:
qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.19.1-x86_64.iso -nographic alpine.img
  1. Login with username root (no password)

  2. 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
  1. Create an answerfile to speed up installation:
wget https://raw.githubusercontent.com/cyberkernelofficial/docker-in-termux/main/answerfile

NOTE: If you see any error like this: wget: bad address 'gist.githubusercontent.com'. Then run this command

echo -e "nameserver 192.168.1.1\nnameserver 1.1.1.1" > /etc/resolv.conf
  1. Patch setup-disk to enable serial console output on boot:
sed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk
  1. Run setup to install to disk
setup-alpine -f answerfile
  1. Once installation is complete, power off the VM (command poweroff)

  2. Boot again without cdrom:

qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img

A - nano run_qemu.sh In the text editor, write the following:

#!/bin/bash
qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img

Save and close the file. In nano, you can do this by pressing Ctrl+X, then Y to confirm saving, and then Enter to confirm the filename.

B - chmod command: chmod +x run_qemu.sh

C - ./run_qemu.sh

  1. Update system and install docker:
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf

apk update && apk add docker
  1. Start docker:
service docker start
  1. Enable docker on boot:
rc-update add docker
  1. Check docker install successfully or not:
docker run hello-world

Some useful keys

  • Ctrl+a x: quit emulation
  • Ctrl+a h: toggle QEMU console

Usage

Now that Docker is installed in Termux, you can start using it to manage and run containers on your Android device. Refer to the official Docker documentation for more information on how to use Docker.

Contributing

If you encounter any issues during the installation process or have suggestions for improvements, please feel free to open an issue or submit a pull request.

Acknowledgment

License

This project is licensed under the MIT License.

docker-in-termux's People

Contributors

amirhoseinsalimi avatar cemkaan avatar dev-bittu avatar nhecker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

docker-in-termux's Issues

Help with VNC connection

I'm stuck in part 7: qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.19.0-x86_64.iso -nographic alpine.img

When I run the command above it says: VNC server running on 127.0.0.1:5900

But I can't access the VNC server using a VNC viewer from my PC using the 192.168.100.X ... address

Am I missing something ?

Can't reach the registry

Good day

I managed to follow the instructions and install docker yesterday. Everything was working fine and I even got hello-world to work. but today I keep getting this error every time I try to search or pull an image.

docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 8.8.8.8:53: read udp 10.0.2.15:36190->8.8.8.8:53: i/o timeout.

Unable to boot [after improper shutdown]; VFS: Unable to mount root fs

Hi,
I am getting this error while trying to boot. (FYI: after unexpected shutdown [low battery/ power off] ; apk was running so this happened) ... Is there a way how to fix it?
Thanks a lot in advance.

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

  1. VFS: Cannot open root device
    or unknown-block(0,0): error -19
  2. Please append a correct "root=" boot option; here are the available partitions:
    [ 5.022423] Can't find any bdev filesystem to be used for mount!
    [ 5.024308] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
    [ 5.027323] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.6.49-0-virt #1-Alpine

QEMU Stuck on "Booting Linux virt" When Starting Alpine Linux

I am attempting to run Alpine Linux (version 3.19.1) using QEMU on my system, but the boot process is continuously stuck at "Booting Linux virt".
I run qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.19.1-x86_64.iso -nographic alpine.img

image

Qemu only uses 2 cores and 1G of memory

My phone has 8 cores and 8G of memory but when running lscpu and free -h in the alpine box it shows 2 cores and 1G of memory can you modify the qemu run command so that it uses all available resources?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.