#homelab in containers on an old spare phone?

77 messages · Page 1 of 1 (latest)

shadow verge
#

Hello everyone!
I'm new to coding, termux, and self-hosting.

I have an idea of what I want to build but lack the knowledge to be able to pull it off haha so anyone willing to help would be great!

I hope to get distrobox running inside a proot-distro debian environment to manage a container lab.

I've got a spare old phone that's been collecting dust and when I found out that there's a way to build a lab with your phone I started digging and ended up in this server.
I don't know much about all the capabilities and limits that termux has. I already rooted my old phone and flashed lineageOS on it but am struggling on building the lab I want.
I saw that docker is supposed to work with termux but whenever I try to start the containers even though I have root on the device the containers won't start.
I recently started messing around with distrobox and really like it so I'd like to use that if possible to navigate the containers, if possible.
There's such a plethora of information and I just want to make sure I'm doing it right, so any help is greatly appreciated!

TLDR;
proot-distro > debian > podman & distrobox > container lab

is it possible? I'm confused about whether it is or not.
How? I'm pretty new so I would really appreciate some guidance.

leaden mangoBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

charred comet
#

@shadow verge

#

I hope to get distrobox running inside a proot-distro debian environment to manage a container lab.

I saw that docker is supposed to work with termux but whenever I try to start the containers even though I have root on the device the containers won't start.

TLDR;
proot-distro > debian > podman & distrobox > container lab

#

ok, so, i will try to help you with what you need to know

#

firstly:

shadow verge
#

Thank you so much!

charred comet
#

if you want real Docker, or real podman, on Android,

#

you need to get your device to pass the requirements of a certain test script

#

and these requirements are more strict than simply having root and having su and sudo working.

#

here is the script your device needs to be able to pass:

#
pkg install wget
wget https://raw.githubusercontent.com/moby/moby/master/contrib/check-config.sh
chmod +x check-config.sh
sed -i '1s_.*_#!/data/data/com.termux/files/usr/bin/bash_' check-config.sh
sudo ./check-config.sh
#

now,

#

if your device does not pass this script at first,

#

you have several options, one of which you already know about

#
  1. to continue to attempt to get real Docker, you need to first be using a custom ROM that also includes a custom kernel, and also be able to recompile your ROM, or at least the kernel, from source, and reinstall it, with different settings and patches set in it.
#

if you want to do that, there are patches, the needed settings, and other directions listed in the FreddieOlivera guide to setting up real Docker on Android:

#
  1. If you don't want to, or aren't able to recompile and reinstall your device's ROM's kernel,
#

then there are things we could call "rootless pseudocontainers" which work without the same technical reqirements as real Docker, real podman or real LXC being necessary,

shadow verge
#

sorry, I don't want to derail you at all but just wanting to know

charred comet
# shadow verge what are the limitations on this?

and they are all based on "proot" technology, which is a thing that's like a chroot, but has some limitations and also a performance impact that real chroots don't have, but the good thing is that "proot" technology works on almost all Android devices, without root or a custom kernel being necessary

charred comet
#
  • moderate performance penalty for particularly file reading and writing, which indirectly can affect the performance of lots of things since lots of things involve file reading and writing
#
  • some limitations around what guest distros can be used successfully in the containers - though if you use popular, normal guest distros like Ubuntu, Debian, Arch then you shouldn't really have a problem
#
  • certain limitations of Android permeate through to the container and cannot be avoided, for one example, if you are using Android 11+ you will most likely not have permission to get the IP address of the device, even inside a proot container
#

however

#

you mentioned already that you have root on your device,

#

that does give you access, if you want, to another option which is, the regular "chroot"

#

regular "chroot" is not affected by the three limitations I described above that affect "proot"-based containers, also, the way you can install and launch a "chroot" in Termux is pretty much identically the same as you would on Desktop Linux, so if you have any experience with "chroot" on Desktop Linux, you would already know what to do and how to use it

charred comet
#

these are the two Termux packages that provide "proot"-based container setups:

#
  • proot-distro
#
  • udocker
#

udocker allows directly running real Docker images from DockerHub using syntax close to the syntax of the real Docker, but since it is running vanilla DockerHub images rather than images tailored for close integration with Termux proot, it might have some unexpected limitations that do not affect proot-distro containers

#

on the other hand, proot-distro is the one that you have mentioned you already know how to use,

#

when you use that, you're already using a "proot"-based pseudocontainer, so that might be sufficient for what you need

#

as for Distrobox: Distrobox has never been documented to work in Termux by anyone, so I doubt you will be able to get it to work without first getting the "real Docker" method I explained first to work on your device, but if you do go that route, I expect it might have a chance of working if you do that, then gradually swap components until you have real DIstrobox instead of real Docker

shadow verge
#

What do you mean by components?
I need an environment to build and practice cybersec things due to school coming up, and also want to access on the go to learn and build the home lab so that I can replicate it on the purposed device in the future or be able to actually use the phone to just host hahaha

charred comet
#

by components, what i'm thinking of is how the Termux docker and containerd packages are patched to work specifically in Android along with the FreddieOliveira guide

#

so, if you got those to work first, they could serve as a test to make sure real kernel-assisted containers are working on your device,

#

then, to swap to Distrobox, I'd guess you might need to adapt some of the patches to apply them to DIstrobox instead of Docker

shadow verge
charred comet
shadow verge
#

I have a PC

charred comet
#

ok, it can vary, but usually it's more convenient to build packages on PC, so first you should read about building Termux packages on PC here

shadow verge
#

however until I start school and have a different job schedule I would like to know how to be able to work on the go

charred comet
#

there is probably a steeper learning curve for that specially for some packages but it will work most of the time

#

these are the commands i'd recommend starting with to practice doing that:

#
pkg upgrade
pkg install git
git clone https://github.com/termux/termux-packages.git
cd termux-packages
scripts/setup-termux.sh
./build-package.sh -I -f grep
cd output
apt reinstall ./grep*.deb
#

this will build the official Termux grep package from source and reinstall the source-built package on your device,

#

this same pattern is generally used for any other package, though you can skip the commands pkg upgrade through scripts/setup-termux.sh if you're doing it again for more packages or the same package again, just skipping straight to ./build-package.sh -I -f [packagename] for subsequent packages, as long as it hasn't been more than about 24 hours or so since the last time you used the first commands

#

once it's been more than about 24 hours since the last time you built a package, it's important that your termux development environment stay up to date, so these commands are important to use about once a day or so after you first set it up:

#
pkg upgrade
cd termux-packages
git pull origin master
scripts/setup-termux.sh
#

package build scripts are stored in the packages, root-packages and x11-packages folders of the repository

#

they should not be run directly, only run through the top-level ./build-package.sh script

#

but you can edit them to edit packages, or copy them to a new folder then edit them there to make a new package or custom package

charred comet
#

packages/grep/build.sh

#

but it should not be built by typing packages/grep/build.sh,

#

only built by typing this:

#
./build-package.sh -I -f grep
shadow verge
#

Alright so to recap, and my purposed way of mapping this;

  • start practicing build packages recently mentioned
  • test whether the chroot method could work
    if not;
  • try following the FreddieOliveria guide and build the patches that I need to apply to get distrobox working over docker
#

does that seem like a good way to try to go about this? @charred comet

#

Also Thank you so much for taking the time to provide all of this knowledge, resources, and entertaining the questions I had through this @charred comet

charred comet
#

yes, sounds good,

#

though, some last advice i should give you is that I would guess that making Distrobox work would probably be very difficult, possibly more difficult than you are expecting,

#

and using just a chroot for what you need (without distrobox) is significantly easier particularly because it is already documented,

#

but making Distrobox work sounds like an interesting challenge and if you really, really want it and are up for a challenge i would encourage you to try it to see how far you can get

shadow verge
#

If I mark this as solved will I be able to add to this thread later on?

charred comet