89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
9.83k stars 401 forks source link

[Question] FreeBSD Compatibility with Distrobox? #637

Open ThisNekoGuy opened 1 year ago

ThisNekoGuy commented 1 year ago

Is your feature request related to a problem? Please describe: I'm not familiar of the possible technical limitations of Distrobox, so I was wondering if it would be possible to use on FreeBSD; and, if not, how likely that could change in the future?

The purpose for the question (personally) is because FreeBSD (technically) does have (janky) support for Linux Steam and a debatably jankier method of running (old versions of) Wine for playing games through Steam, so I was hoping that using Distrobox as a gaming work-around would be a more effective possibility.

Describe the solution you'd like Possibly a Distrobox solution for enabling FreeBSD compatibility

Describe alternatives you've considered Just not using FreeBSD:sob:, though I ask this in hopes of bettering its software availability

Additional context In case someone unfamiliar asks "why not flatpak:" that's not a FreeBSD compatible solution, as far as I'm aware, due to Flatpak requiring Linux Namespace support from the Linux kernel itself for which there is no *BSD compatibility solution.

89luca89 commented 1 year ago

Hi @ThisNekoGuy

distrobox depends (for now) on either podman or docker, so for it to work anywhere, it needs one of those to work

due to Flatpak requiring Linux Namespace support from the Linux kernel itself for which there is no *BSD compatibility solution.

The technologies at the base of distrobox (either docker or podman) are containers, which use kernel's namespaces to work

ThisNekoGuy commented 1 year ago

Apparently, they both have FreeBSD ports 🤔 How, I'm not sure; given what you said

https://ports.freebsd.org/cgi/ports.cgi?query=podman&stype=all&sektion=all

https://ports.freebsd.org/cgi/ports.cgi?query=docker&stype=all&sektion=all

89luca89 commented 1 year ago

Worth a try @ThisNekoGuy I don't have any *BSD handy now, let me know how it goes :)

ThisNekoGuy commented 1 year ago

I was actually asking because I didn't want to take thenplunge into BSD territory by wiping my system to do so if it isn't possible :v I would be the guinea pig if I had spare hardware, but I don't...

89luca89 commented 1 year ago

That's ok, if someone else is interested in this, we'll gladly hear the outcome :)

luc14n0 commented 1 year ago

Hi there,

The fundamental problem here isn't Distrobox itself really, but FreeBSD. There have been efforts to make Podman functional under FreeBSD? Yes, but Podman on FreeBSD will run... FreeBSD containers. To run Linux containers on FreeBSD you need something else like Containerd, and even though this is all still experimental, as far as I can tell.

So, let's assume that Linux emulation is mature enough (I can't really say whether this is the case at this moment) and someday -- if the day comes at all -- Cointainerd also matures on FreeBSD enough to allow running smoothly Linux containers on FreeBSD. Then somebody can start thinking on possibilities on Distrobox side of integrating Containerd with the goal of running it under FreeBSD.

Now, since Steam was mentioned it's worth mentioning that the idea of using Distrobox to run Steam on FreeBSD is not good, in general. Why, you ask? Because we'd be putting layers after layers of abstraction upon each other.

Steam itself under Linux is only officially supported under Ubuntu, other distros have to go through their hoops to make packages available, and it's basically a "container" based on (yes, you guessed) Ubuntu -- I'm not familiar with Steam running directly on Ubuntu, though, so I can't say how differently it runs there compared with other distros -- that uses Proton (a fork of Wine) to avoid all the nuisances of porting games to run natively on the numerous Linux distros out there.

Running games on Linux through Steam can be a challenge already depending on the choices of both hardware and game we make. Running games on FreeBSD is even more challenging because Valve doesn't produce a Steam client for it. Although I honestly can't say, or even imagine, which solution is better on FreeBSD: using Linux Steam through Linux emulation or Windows Steam through Wine; I wouldn't hold my breath for running Steam games with the help of Containerd (and if someone brings Containerd to the list of supported container technologies on Distrobox) plus Distrobox.

0x006E commented 8 months ago

The fundamental problem here isn't Distrobox itself really, but FreeBSD. There have been efforts to make Podman functional under FreeBSD? Yes, but Podman on FreeBSD will run... FreeBSD containers. To run Linux containers on FreeBSD you need something else like Containerd, and even though this is all still experimental, as far as I can tell.

Actually now, podman is able to run Linux containers (instead of containerd). The freshports mentions an example (sysutils/podman, check the pkg-message section) and it works, you can run a linux container under FreeBSD. But you cannot run podman as rootless. I am experimenting with distrobox to achieve a working box. Maybe in the future when things are not janky as this, distrobox will work with freebsd nicely

quicktrick commented 8 months ago

FreeBSD + bhyve + any Linux VM (I usually use Void Linux) + docker or podman, etc. This is an excellent solution, I use it a lot.

bogen85 commented 1 month ago

podman on FreeBSD 14 .1-RELEASE runs Linux containers (with a bit of setup, not applicable for me to describe here). I've had some success at doing so, but there are limitations.

Linux xattrs in the container image need to be removed otherwise the container will not start. This can be done with exporting the container, unpacking it, and repacking with bsdtar and removing the xattrs. The alpine and rocky containers on dockerhub were fine, but not almalinux. I was able to get almalinux working by stripping xattrs via bsdtar.

$ sudo podman run --rm -it --os=linux alma94 /usr/bin/bash --login -i
bash-5.1# uname -a
Linux ddbee4a320af 5.15.0 FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC x86_64 x86_64 x86_64 GNU/Linux
bash-5.1# fgrep -i alma /etc/os-release 
NAME="AlmaLinux"
ID="almalinux"
PRETTY_NAME="AlmaLinux 9.4 (Seafoam Ocelot)"
CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"
ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"
ALMALINUX_MANTISBT_PROJECT_VERSION="9.4"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"

Also not all networking works due to unsupported syscalls. But ping, nslookup, fetching from repos, etc, does work, so packages can be installed.

But stripping the xattrs as noted above does not get one completely out of the woods. If in a container and installing a package that set xattrs, one must download the package and use an install option that does not apply the xattrs.

In almalinux (and rocky linux) top and atop work and show processes, but htop does not show any processes.

FreeBSD's Linux compat has an updated kernel version for Linux, better than what it was a few years ago.

$ cat /compat/linux/proc/version 
Linux version 5.15.0 (des@freebsd.org) (gcc version FreeBSD Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9)) #4 Sun Dec 18 04:30:00 CET 1977
bogen85 commented 1 month ago

podman on FreeBSD 14 .1-RELEASE runs Linux containers (with a bit of setup, not applicable for me to describe here). I've had some success at doing so, but there are limitation

Oh, and podman on FreeBSD is currently only rooted, so no rootless benefits offered by distrobox, as it would be limited to rooted distrobox containers. Would not be an issue for me, as I primarily use rooted distrobox instances.

bogen85 commented 1 month ago

That's ok, if someone else is interested in this, we'll gladly hear the outcome :)

I might be able to take a stab at it. Everything looks to be shell scripts (which may be an issue as far as compatibility between BSD and Linux). Would only be for rooted podman. I'm currently using distrobox from x86_64 EPEL9.