distrobox
distrobox copied to clipboard
[Feature] MacOS host support
Is this an effort worth exploring?
Yea I would like in the future to support it, what blocks me for now is the host integration
On MacOS podman runs in a VM, and distrobox integrates with the container's host, which in this case will be the VM, not the MacOS host So it becomes quite a limited experience, without exports of stuff or graphical apps integration
I'm gonna keep this issue for the future and mark it ad blocked until we either find a solution or we create a piece of documentation that explains the situation and does not confuse the users
Ironically I think (not tried yet) that distrobox on WSL2 could retain some real host integration seeing how the linux VM is tightly integrated with the Windows host :shrug:
Yea I would like in the future to support it, what blocks me for now is the host integration
On MacOS podman runs in a VM, and distrobox integrates with the container's host, which in this case will be the VM, not the MacOS host So it becomes quite a limited experience, without exports of stuff or graphical apps integration
I'm gonna keep this issue for the future and mark it ad blocked until we either find a solution or we create a piece of documentation that explains the situation and does not confuse the users
Ironically I think (not tried yet) that distrobox on WSL2 could retain some real host integration seeing how the linux VM is tightly integrated with the Windows host 🤷
Tried with an Ubuntu WSL install, got an error, I'll try other distros later.
Yea as said I didn't try 😂 Anyway that seems an incompatibility between wsl2 and podman probably? Maybe there are some guides for it Distrobox works with docker too I think that shouldn't have problems
Anyway I'd stick this conversation to macos and in case there is interest open a new one for WSL2 (I doubt WSL1 will work)
I just discovered distrobox, and this was the first thought I had. I have to use a Mac for work, but would love to be able to use this for a bunch of stuff.
Although podman might be difficult, maybe docker would work better, due to it's somewhat better integration into the host with HyperKit (hypervisor).
I'm not really sure of the specifics of how that works, but it might be a consideration.
On Dec 29, 2021, at 09:26, Dan Jones @.***> wrote:
Although podman might be difficult, maybe docker would work better, due to it's somewhat better integration into the host with HyperKit (hypervisor).
Docker also runs in a VM on Mac OS
If the goal is to containerize and not isolate, why not consider distributing a light-weight Kubernetes distribution with this project? Something like k3s or Minikube would work perfectly for this and it has the added advantage of being able to run on Windows, Mac OS and Linux.
All of them share the VM problem anyway, podman docker k3s, minikube all work inside a linux VM I think it would be doable as a way to have something to have pet containers for dev environments, but I see it difficult to have the level of integration that can be achieved on a Linux host
Let's follow this as it's a blocker for now: https://github.com/containers/podman/issues/8016
My two cents are that I'd love to have distrobox on macOS regardless of the lack of integration, as an easy way to automatically spin up lightweight VMs for various uses. I love WSL on windows and just installed distrobox on a linux machine and it's amazing there too, would love to have some analogue on macOS
Well the point of toolbox/distrobox type of software is the tight integration with the host If I cannot provide this integration it's just like using podman/docker
On MacOS right now I'm not even sure graphical apps can work inside distrobox with podman-machine
While i totally agree that tight integration with the host is what makes distrobox amazing i think there is some amount of usage for macos... I wanted to work on my personal distrobox container today and didnt have my linux machine near by and ended up doing podman build...
and podman run...
to be able to mess with it a little... but the problem is i still didnt have my user setup correctly as distrobox automagically does for me... but i also would rather not add a massive amount of bloat to this project just to support a weird usecase... this project is so fantastic already id hate to taint it with an extra chunk of bloat to have to maintain...
It might be worth investigating colima and/or lima for macos support rather than podman as it offers tighter integration with the OS out of the box. (Still a vm however)
@JakeHL will investigate, I don't have a Mac so it might take some time :smile:
I daily drive an m1 macbook, Let me know if I can be of help. I'll take a look in the meantime. Would love to see this up and running
This would be increadible - mac os is the only option at work
1+
Let's follow this as it's a blocker for now: containers/podman#8016
Heads up, looks like that blocker is now closed on the podman side of things: https://github.com/containers/podman/issues/8016 :)
I think podman honestly just over complicates things. Lima should be perfect for something like this - it allows for invoking commands inside a VM, sharing state between host and VM etc. Honestly its not far from doing what distrobox already does. Ive started to play with it to create a distrobox like experience and its been pretty great. Ive not tried integrating actual distrobox yet though.
@jakehl Hey Jake, is your work available somewhere to play with? Sounds very useful :)
Its not, its just crappy shell aliases and functions to try and recreate the behavior. If I can get some time over the holiday break I'll tidy it up and push it.
ok so i started messing with getting distrobox installed on macos, the install script uses install
which is a different version from what is on macos so i did brew install coreutils
and then replaced install
with ginstall
to get all the distrobox scripts put into place, that worked... So that would need to change in some way for mac compat
Next problem is when i go to run distrobox create
I get this:
Error: failed to connect: dial tcp [::1]:51787: connect: connection refused
An error occurred
An error occurred
lol that error was because I didnt have my podman machine running 🤦🏻♂️... more errors on create using podman Error: statfs /Users/kevindurbin/.local/bin/distrobox-export: no such file or directory
... testing docker...
container stays stuck in CREATED
... I think its due to performance of mounting all of ~
with macos docker...
lol that error was because I didnt have my podman machine running 🤦🏻♂️... more errors on create using podman
Error: statfs /Users/kevindurbin/.local/bin/distrobox-export: no such file or directory
... testing docker...
Yes, this is because some parts of distrobox (init, host-exec, export) are mounted inside the container itself In case of lima and other VM based solutions (which includes docker), the path of distrobox is not present, nor the same as inside the VM So this will create errors
Podman on macos is also a VM based solution. I dont know of any container system that doesnt run on a vm on macos.
Ok so back to this... im on an M1 mac running ventura now and ive got the experimental rosetta 2 emulation and virtio (docker btw)... I think this is the best chance we have to make this work performantly. create
works great and then when I enter
i get the following error
Container dev is not running.
Starting container dev
run this command to follow along:
docker logs -f dev
Error response from daemon: path /host_mnt/private/tmp is mounted on /host_mnt/private but it is not a shared or slave mount
Error: failed to start containers: dev
Yes, this is because some parts of distrobox (init, host-exec, export) are mounted inside the container itself...
What is the path it should be mounted at? Lima has great mounting options to share filesystems between host/guest. I'll see if I can get it working.
looks like theres an extensive list of volumes that get added, if you look at distrobox-create generate_command() function you can see it add all the volumes in. heres the initial list, i assume that /tmp
is the one associated with the error, gonna attempt to just not mount this... but i'm also wondering if theres something broken with macos and rslave
mounts...?
--volume /:/run/host:rslave
--volume /dev:/dev:rslave
--volume /sys:/sys:rslave
--volume /tmp:/tmp:rslave
--volume \"${distrobox_entrypoint_path}\":/usr/bin/entrypoint:ro
--volume \"${distrobox_export_path}\":/usr/bin/distrobox-export:ro
--volume \"${distrobox_hostexec_path}\":/usr/bin/distrobox-host-exec:ro
--volume \"${container_user_home}\":\"${container_user_home}\":rslave"
yea it seems like theres something macos doesnt like about rslave mounts... i have no clue what an rslave mount is so gonna do some research to see what this does and maybe theres an alternative for macos
https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation
Mount propagation doesn’t work with Docker Desktop.
Well theres that answer lol
ok so i was able to enter the container 🎉
I removed the following mounts: /, /dev, /sys, /tmp
and changed the user home mount to not have rslave
bind propagation, when i ran distrobox enter
the first time it said Starting container...
then exited silently. I ran it a second time and it dropped me into my container! So maybe with macos we could have a limited functionality mode or maybe something like lima can do bind propagation?