This reads a bit like "when all you have is a hammer" because it seems like what you want is a VM, not a container[^1]. Have you considered using VM software instead of Docker and using an Ubuntu VM directly? Some options:
I have used VM softwares before and would have preferred using them in all honesty. This was more of an exploratory "can I do this? if yes, how far can I take it?" exercise. I just wanted to see how much effort would it take if I just wanted to "simulate" stuff (turns out 4 measly scripts). Plus I already use Docker in my work. This helps me avoid installing the VM software separately.
> Strictly speaking, OrbStack machines are not independent VMs, but they're virtually indistinguishable for most intents and purposes — just with better integration. This is why we choose to call them "machines".
I have been using Multipass [0] for a while and it works great to quickly spin up an Ubuntu environment on my MacBook. It supports cloud config in case you want a custom instance.
It seems to be limited to running Ubuntu instances only (at least, I haven't figured out how to run other Linux instances) but if you want a quick clean Ubuntu VM I would recommend it.
Multipass is pretty clutch for trivial VMs on MacOs for sure. I use it for a bunch of ssh jump boxes running vpns to different sites. The macOS build does not support custom images (lest not without [some truly insane hacks](https://github.com/canonical/multipass/issues/1260#issuecomm...) , which doesn’t really matter for what I use it for but it is kind of a bummer. If you need something with a little more grunt but don’t want to go full blown with writing your own QEMU tooling or fussing with something like UTM or Parallels, [quickemu](https://github.com/quickemu-project/quickemu) is a really nice qemu wrapper with sane defaults that can expose a whole lot of power if you need it.
This looks quite interesting! Much more elaborate in options I guess. Though the limitation to Ubuntu is something they should look into expanding. Does it also allow me to persist state?
Just to see if I can. Just a small weekend exercise.
"Complexity" might be subjective though, but then again it looks simple to me because I made it, so I might be excessively biased.
Lima is what I use as well. It's quick and easy to just fire up a VM with default settings, but also very easy to configure with different file sharing options, port forwarding, different linux distributions, etc. (their examples are also pretty good IMO [1]).
In particular I use it to run an amd64 VM, which I need to run a stubborn service for work that doesn't run on arm CPUs.
From TFA, the author mentions things like `date` having different args on Mac (BSD utils) and Linux (GNU utils). While true, you can just install GNU utils on a Mac, and get access to all of those, prefixed by g (e.g. GNU sed is launched with gsed).
Linuxify [0] is a decent shell script that does all of this for you.
If you use Macports (much more consistent than homebrew and much more attentive to the way MacOS works and MacOS SIP etc works) then installing the GNU utils ports gives you a standard GNU environment, so pretty close to Ubuntu/Fedora etc.
Of course, networking etc and DNS and other system services will be the native MacOS, but MacOS is a Unix. It has its own init with launchtl and DNS/mDNS with scutil and mDNSResponder.
You can also do the same thing just with homebrew. I regularly replace a number of CLI utils because the BSD alternatives often have silly defaults/incompatible changes
Yeah, the script is just calling brew install over a list anyway.
I also outright replace sed and awk with their GNU equivalents. Better options and behavior, IMO. The only downside is if you have to share a script with someone, and then have to figure out how to make it work with stock.
Yep, used to use linuxify a few years back. But then it used to mess with my internal scripts. Anyhow, this was just a "what-if" exercise. Plus, Ubuntu was a test OS, but CentOS/RHEL were real PITA on client systems and this gives me a quick way out from spinning up a VM while still maintaining control. But agreed, if I just wanted GNU utils, I'd have just gone ahead with linuxify.
I use multipass to run Ubuntu VMs on macos (m1). It works flawlessly. Zero issues so far (I keep around 3 or 4 VMs running in the bg and they still work after days/weeks with no issues regarding the network or whatever)
A big flaw in this approach is that the `ubuntu:latest` VM is not necessarily the same userland as a real Ubuntu installation (e.g. Ubuntu Server 20.04 != ubuntu:20.04).
Anything that has a base Docker image available, this would work. RHEL, Debian, etc should work without much effort. I have not seen older OSX Docker images so probably not. Windows server does offer some base docker images.
https://mac.getutm.app/
https://tart.run/
https://orbstack.dev/ (using its "machines" functionality)
[^1]: Of course macOS docker is running a Linux VM under-the-hood, but that's an implementation detail.