How to add Docker support on Android?

So first let’s talk about what docker is.

Docker

is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.[6] Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.[7] Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.[8]

CC: Docker (software) - Wikipedia
That is what docker is as per wikipedia.
If I were to break it down in layman terms:

Docker is a software that one can use to run different Operating Systems(OS) in a containerized environment.

What we are going to do today is to try enable the docker support on Android.
This is not natively possible and requires the person to recompile the kernel with the required configurations enabled.

Bear in mind this guide is not for newbies because the terms used in this guide is specifically geared towards kernel developers!

Let’s get started!

First off, download the patching script

wget https://raw.githubusercontent.com/cyberknight777/Kali-NetHunter/main/scripts/docker.sh;chmod 777 docker.sh

Then you’d need to execute the script with the path to kernel tree as an argument.
Once that’s done follow instructions given by script to enable the required configurations and then compile the kernel :).

You may face some issues when compiling fs/btrfs. To fix that try compiling that code with Google Common or CAF or even Linux-Stable.

After compiling the kernel, flash it and then install PWN-TERM.
After running setup, install docker via

apt install docker

Then run

sudo dockerd

Open a new session and run

sudo docker pull arm64v8/debian

Then type

sudo docker run -ti --net=host arm64v8/debian

And Voila!, you will be in a containerized debian environment.

To get network access you would probably need to check /etc/resolv.conf. If that file is empty, run this

echo “nameserver 8.8.8.8” > /etc/resolv.conf

Once that’s done you’d need to do this in all other operating systems except for alpine

groupadd -g 3003 aid_inet && usermod -G nogroup -g aid_inet _apt

Next just try doing apt update and you will see that network is working.

Enjoy your containerized environment :slight_smile:


Some people I’d like to mention for their work in docker:-
@FreddieOliveira for his great guide.
@martinvlba for his PWN-TERM and docker package modifications.
@Xeffyr for his work in adding docker package in termux and helping in getting network working in containers.


Stay tuned for more interesting Content!

:o: Know more about us :point_down:
https://cybernity.org | Telegram: Contact @vyuhainfinity

6 Likes