Apple Container Machines are a new feature that gives you lightweight, persistent Linux environments on your Mac, built on top of last year's Apple Container project and optimized for Apple Silicon.
📌 Chapters: 0:00 - Intro (WSL for Mac) 0:29 - Creating a Container Machine 1:48 - Inside Linux 2:09 - Home Directory Sharing 2:42 - Develop on Mac, Test on Linux 3:56 - Multiple Distros & systemd 4:28 - Design Principles 4:48 - How It's Built 5:40 - Benchmarks vs Docker & OrbStack 6:27 - The Catches 7:32 - Final Verdict
0:00 Introducing Apple's Container Machines and the Container Tool
1:30 Setting Up and Using a Container Machine with Ubuntu
3:40 Benefits of Container Machines for Development and Cross-Platform Testing
5:30 How Apple's Container Technology Compares to Docker and Orbstack
6:30 Limitations and Final Thoughts on Using Container Machines
Apple has introduced \"Container Machines,\" a lightweight, persistent Linux environment for macOS optimized for Apple Silicon. Similar to Windows Subsystem for Linux (WSL), it allows users to run OCI-compatible images (like Ubuntu) as VMs with seamless home directory sharing, providing a streamlined workflow for cross-platform development and testing.
Hidden behind all of the Apple intelligence stuff at WWDC this year, Apple quietly released
their own version of Windows' subsystem for Linux called Container Machines.
These give you a lightweight, persistent Linux environment on your Mac in a really easy-to-use
way, and they're actually built on top of Apple's Container Project, which they released
last year, which is a Docker alternative, all of which, of course, is optimised for
Apple Silicon.
So let's take a look at what Container Machines are, how they work, and I'll also do a quick
recap of Apple Containers for everyone who missed them.
So I'm going to start by setting up a Container Machine, and then I'll talk through how all
of this is working in a bit, but the one I want is going to be a Ubuntu Linux environment,
so I simply have a Dockerfile here with the Ubuntu image, and then some things in here
to install some common tools.
This will work with any OCI-compatible image, so pretty much all of the ones that you have
working with Docker.
The only thing it needs to include to be a VM is the system initialisation program.
Once we have the Dockerfile or image that we want to use for our VM, all we need to
do is build this using Apple's Container tool, so you can see this is the command that I'm
using for mine, since I have the Dockerfile in this folder, and I'm simply going to tag
this as local-ubuntu-machine, and we can go ahead and hit enter on that and build.
The Container tool, by the way, works on Mac OS 26 and above, and you can install it from
GitHub by simply going to the repo, going to releases, and downloading the latest package.
It looks like the build of my image is done here, and you can see it's very similar to
Docker, it's just building an OCI image.
That's all we need for a Container Machine, so now we can simply run container-machine-create,
say the image that we want for our Container Machine, give it a friendly name, and I'm
also going to set this as default, so any command that I run is going to assume I'm
about this Container Machine, and I don't have to specify it by name.
With this, we can hit enter, and in literally seconds, it is all set up.
We can see a bit of information about the Container Machine that I just created by doing
container-machine-list.
Here you can see it has the Ubuntu one that I just created, the IP address, 7 CPUs, and
18 gigabytes of memory.
CPU and memory are configurable, by the way, but by default, it will use half of the memory
of your Mac.
To actually get using your Container Machine, though, all you need to do is container-machine-run,
and you can leave this blank if you want to enter the interactive terminal, or you can
actually just add a command after that if you want to run that on your Linux machine.
In this case, you can see I just hit enter, and now I'm on an interactive terminal on
my Linux environment.
We can confirm this by doing something like uname-a, and you can see this is printing
back that it's Linux Ubuntu, as opposed to when I run this on my Mac, and we get back
Darwin.
Now, one of the cool things about Container Machines is it's got automatic user sharing,
so my user has already been copied from my Mac onto my Linux environment, and the same
actually goes for your home directory.
This will mount your entire home directory as read-write, so I have access in this Linux
environment to all of the files that I have on my Mac, and you can see where I actually
ran container-run, it's put me straight into that file in the Linux environment, and we
already have those files in there.
It does also have its own volume, though, so if we navigate to the home directory of
this Ubuntu machine, you can see there's currently nothing in there, even though there is on
my Mac, and that is because this one is the Linux environment, and this is where you'd
put your .files that are specific to Linux.
The folder sharing makes it super easy to develop something on your Mac using all of
your normal tools, and maybe even some that are only compatible with macOS, and then simply
switch to Linux when you need to test something.
For example, I have a very simple bun application here, and I want to compile this into a single
executable that will work on Linux, but I can't actually test Linux on my macOS, so
running this, I don't know whether it's worked or not.
If we switch over to the container machine, though, you can see I can simply run the command
straight away, I don't have to transfer files or anything, thanks to the fact that it shares
the same file system, if I hit enter here, it works nicely.
This application was just a very simple web server with this webpage here, which prints
what it's running on, so it's currently running on Ubuntu 24, you can also see there's a subscribe
going around, something you should definitely do.
Now I was just testing out running the bun development server on the Linux environment,
and it does all work, which we can see here, it's running on bun-dev, and it's not compiled,
but if I modify one of the source files from my Mac here, maybe say hello instead of subscribe,
I am noticing that the hot reloading doesn't seem to be picking up on that behaviour, and
I have to restart the bun development server to get the changes to apply.
There we go, now it says hello.
I think hot reloading will work the same way that breakpoints do, where they don't actually
work if you're on your macOS code version, but what you can do is get your editor to
connect to the container machine via SSH, and then edit the files that way, and that
way breakpoints and hot reloading will probably work.
They actually have a tutorial for how to do this in their documentation.
That's basically all there is to show you when it comes to actually using a container
machine, I mean it's just a Ubuntu environment now, and honestly the whole experience is
pretty seamless.
It's also worth pointing out that you're not limited to just one machine, you could have
an Alpine machine, a Ubuntu one, and a Debian one sitting side by side, so you have one
distro per target, and honestly it's very nice if you're doing cross-target work.
Plus, because these machines can actually run a real systemd, you can test a proper
service stack in there, like having Postgres running as an actual service, with your app
next to it, and the whole thing is going to behave like the Linux server that you're going
to deploy to.
The simplicity is one of the core design principles that Apple was pushing for when developing
container machines.
They wanted fast, lightweight VMs that integrate into your existing workflow, and are super
easy to spin up as needed, as well as be persistent over time so that you can set up a whole dev
environment VM that has all of the tools that you normally need, ready for when you need
them.
Again, it's pretty similar to what Windows' subsystem for Linux was trying to achieve.
As for how all of this is built, and how it compares to Docker and Orbstack, we first
need to understand the container tool that was released last year.
This is written in Swift, and it's meant to be a Docker alternative that can run containers,
and it runs any standard OCI image, so anything that you can pull from Docker Hub is still
going to work.
The unique thing about Apple's approach though, is that every container got its own lightweight
virtual machine, through their virtualization framework, rather than a bunch of containers
sharing one big Linux VM, which is what Docker Desktop does.
Some benefits of that approach can be security, since each container has the isolation properties
of a full VM, then there's also privacy, since you're only mounting the necessary data into
each VM, whereas when you have a shared VM, you actually mount all of the data into that
shared VM, so it can be mounted selectively into the individual containers.
Finally, there can also be a performance benefit, since containers created using Apple Container
actually require less memory than a full VM, and the boot times are pretty similar to Docker
and other tools.
If we actually look at some benchmarks that Repo floated here, comparing Apple Containers
with Orbstack and Docker Desktop, we can see the results aren't actually too bad.
It's hard to tell here, but Apple Containers actually does achieve the most single-threaded
CPU events, but Orbstack was pretty close, there is fractions in it, and that same story
continues when we go to multi-threaded as well, they all perform very well.
Where Apple does seem to pull a bit of a lead though, is in memory throughput, with Orbstack
coming in second, and Docker Desktop last, but when it comes to startup times for a tiny
container, it seems that Apple does have some work left to do here, but it is still sub-second,
it's just Docker Desktop and Orbstack do it in less than a quarter of a second.
There's loads more benchmarks here, so I'll leave a link to this, but basically the rest
of them show that Orbstack has exceptional file system and small file performance, but
they also show that Apple Containers is pretty much level, if not better than Docker Desktop.
There is a few catches though that you'll want to be aware of before you use container
machines, and the first one is memory.
As I mentioned earlier, the machine defaults to half of your system RAM, so it is worth
knowing that it actually never gives this back, so if you have a memory-intensive workload
in the container, maybe during a big build, that memory is actually held until you restart
the machine.
This is actually one of the unique benefits of Orbstack, where it has dynamic memory,
which reduces the memory usage by releasing that unused memory back to macOS.
As far as I know, nothing else does this.
Second, there's also no GPU and USB pass-through.
I have seen open issues for both of these on that GitHub though, so maybe it'll be supported
in the future.
Third, it also seems a little complex to get GUI apps running, like maybe if you wanted
to run the Linux version of VS Code or other Linux-only apps.
It's definitely not a seamless experience, I'd probably use something else for this.
Finally, there's also a security trade-off, because as I mentioned earlier, that home
directory mount that makes everything so convenient is read-write by default, which means that
anything that you run inside of that Linux machine can touch your SSH keys, your cloud
credentials, and everything on your Mac.
It seems you can actually only set the mount to read-only or turn it off entirely.
There doesn't seem to be an ability to only mount a specific folder.
Overall, having tried out Apple Container Machines, I'm probably going to stick to
Orbstack as it feels like the more polished option today with better resource management
and more features, but I know some people don't like that Orbstack is paid for if you
want business and commercial use, so without Orbstack, I probably would choose Apple Containers
over Docker Desktop, and there's also Kalima which is another great alternative.
What do you use?
Is it Orbstack, Docker Desktop, or Lima?
Let me know in the comments down below, while you're there subscribe, and as always, see
you in the next one.