This guide provides a method to create a Docker like, isolated environment on Android devices using Termux. It allows advanced developers to deploy Python bots or applications on rootless devices. This setup uses a chrooted Ubuntu environment within Termux for enhanced isolation and compatibility.
Warning: This is intended for advanced users only. Ensure you understand the steps, as improper execution may lead to issues with your Termux setup.
Prerequisites:
- Termux installed (refer to our Kali NetHunter repository for setup instructions).
- Android device with sufficient resources (at least 2 GB RAM recommended).
- Basic knowledge of Linux commands and Python development.
Run the following commands in Termux one by one:
pkg install git -ypkg install wget openssl-tool proot -y && hash -r && wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Installer/Ubuntu/ubuntu.sh && bash ubuntu.sh./start-ubuntu.shapt update && apt full-upgrade -yapt install python3 -yapt install python3-doc python3-venv python3.13-doc binfmt-support python3-tk python3.13-venv binutils -yapt install cpp-doc flex bzr gcc-14-locales bison gdbm-l10n ed cpp-14-doc gdb diffutils-doc debian-keyring gcc-doc ncurses-doc perl-doc gcc-14-doc readline-doc libterm-readline-gnu-perl libc-devtools sqlite3-doc libterm-readline-perl-perl autoconf glibc-doc libssl-doc libtap-harness-archive-perl automake sensible-utils libstdc++-14-doc libtool git make-doc -yapt install wget libncurses5-dev build-essential zlib1g-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev pkg-config -yapt update && apt full-upgrade -ywget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tgztar -xf Python-3.12.*.tgzcd Python-3.12.*/
./configure --enable-optimizationsmake -j $(nproc)make altinstallpython3.12 --versioncurl -sS https://bootstrap.pypa.io/get-pip.py | python3.12pip3.12 -VUse pip3.12 install <package> to install modules .
- Move your bot scripts/files into the Ubuntu environment (e.g., create a directory called
bots). - Navigate to your bot's directory.
- Create and activate a virtual environment:
python3 -m venv .venv && source .venv/bin/activate- Install required pip modules for your bot.
- To run the bot in the background without deactivating the venv, prefix your bot's start command with one of the following:
nohup <your-bot-command> &(Recommended: Provides output, auto-restarts on crash).setsid <your-bot-command>disown <your-bot-command>pm2 <your-bot-command>(If pm2 is installed via npm; install Node.js if needed).
- Enable wake lock via the Termux notification to keep the process running.
- Exit Termux using the
exitcommand (do not close the notification). Your bot will now run persistently in the background until manually stopped.
- If compilation fails, ensure all dependencies are installed and retry.
- For wake lock issues, re-enter Termux, request wake lock again, and exit properly.
- If your bot crashes, check logs (especially with
nohupfor output files likenohup.out).
Input the below command into Termux to get rid of the env.
wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Uninstaller/Ubuntu/UNI-ubuntu.sh && bash UNI-ubuntu.shThank You
The DresOS Team
For questions or issues please contact us via our website: https://dresoperatingsystems.github.io/