New containerization framework

As someone from the :cloud: cloud native :cloud: world, I’m so excited to see the open source release of a new containerization framework today! Super cool to see Swift being utilized for server-side and cloud native development!

For those of you who’ve always wanted to write Mac native Linux containers — check out container :backhand_index_pointing_down:

For those of you who want to check out the Swift framework and contribute — check out containerization :backhand_index_pointing_down:

Would love to hear what you all think about the releases!

25 Likes

Are there any plans to support BSD or other operating systems also, or is there anything linux-specific to this effort? I recently picked up my first Mac in two decades and am looking forward to using this or UTM. :smiley:

2 Likes

A lot of containerization stuff is inherently Linux-specific. The way to run other operating systems with containers is to do something like running an emulator in your container and supplying a VM image -- I haven't looked too closely at this yet, but I think this is basically facilitating this process, especially given these are Linux containers running inside macOS.

But that doesn't necessarily mean one can supply an arbitrary image in a container and expect it to work here, for example, since most of this stuff is oriented for Linux; especially since the macOS Virtualization framework only seems to supports Linux kernel/initrd booting, which the BSDs don't use.

Not how this works, they're already spinning up a VM per container, ie the OS run in the container is not shared between containers. Sure, you usually have to resort to running a VM in the container for other more limited solutions, but I hope that won't be the case here, at least eventually.

Others have gotten the BSDs working years ago, so I don't think that's the case.

Obviously these new containers are currently geared towards linux, but given the current effort by some Apple devs to get Swift on FreeBSD and the seeming ability to run many different OSs in the underlying Virtualization framework, I wondered if these containers might support BSD and other OSs next.

I definitely plan to try it on UTM for mac without invoking QEMU emulation, just wondering if I could with this new framework too.

1 Like

What I'm saying is, if you had a disk image for a different OS and you were doing this on a Linux host, you could run qemu inside your container with a disk image. But I think what is happening here is that these are the equivalent of Linux KVM virtual machines being run here, except the acceleration is happening on xnu instead.

Ooh, neat. (For the record, this uses VZEFIBootLoader)

Yep, I'm agreeing with you that other container solutions are more tied to the host OS, so the only way to run alternative OS's in those containers is to run a VM inside the container.

But since this is in reality a VM solution, where the "container" seems to really just be about standardizing the VM image format somewhat, I hope we can have BSD containers too. :grinning_face:

I'd love to run an OpenBSD container with this new container framework one day. :smiling_face_with_sunglasses:

1 Like

Now that there is official FreeBSD support, I hope support of FreeBSD OCI containers makes it into Containerization, and eventually, we end up with Containerization running with FreeBSD as one of its hosts. :-)

1 Like

I don't really understand what the reason is using the container.
When I use docker container, I expect the code can deploy on different OS as long as docker supports the OS. But this containerization framework only can run on macos.

Am I misunderstanding something?

My understanding is that the containers that are used are OCI compliant, which means they can be hosted on Docker, Podman, this new Containerization framework, etc.

Apple Container is a Container Runtime means to run any 'Linux' container on macOS, just like Docker and Podman.

You don't build Docker container, you build image based on an OS (usually Linux) and that can be deploy on an OS with a compatible kernel (this is required as the container uses the host kernel).

An amd64 linux image cannot be deployed on anything but Linux host (which can be a Linux lightweight VM) capable of running AMD 64 software.

Moreover, images don't need Docker to run, they just need a container runtime (crun, runc, …).

Most images are deployed in container orchestrators like Kubernetes that do not use Docker at all.

Being able to build run an image on macOS is critical to write softwares that should be deployed as containers elsewhere, and that what this software is about.

“Being able to build run an image on macOS is critical to write softwares that should be deployed as containers elsewhere, and that what this software is about”

Does it mean the host has to be macOS?

So, the image I was created from docker, the container from this image can also be ran on this containsation framework?

Please, reread the package README. It contains a lot of information like:

Containerization is a Swift package for running Linux containers on macOS.

Yes, I saw that. On Mac only. Therefore I think there is no point in using it.

Indeed, if you are not using macOS, or have no need to build and run Linux Container, that new framework and tool will not be very helpful to you.

I run Linux container. But I expect the dockerfile I created can run on different systems.

A containerized Linux application can run on any host that supports Linux containers. This library and tool enables a containerized Linux applications to run on macOS, which is not normally possible.

1 Like

It would be more exact to say "an alternative way to run Linux container on macOS", as podman (via podman machine) and docker already let you do it.

This Framework provides a different approach though as it runs one lightweight VM per container, and as it is designed as a library, it can be use to create new tools to managed containers on macOS.

3 Likes

Heh, I was surprised to see that this is now the fourth most upvoted Swift link on HN, the most since the initial and open-sourcing announcements a decade ago, appears to be a lot of developer interest in this new containerization framework.

A lot of questions about how lightweight these separate linux VMs can be, whether 10 containers run 10 separate linux kernels with no sharing or if there is some underlying resource sharing going on.

@karenchu, maybe you could get one of the engineers like Crosby to discuss those tradeoffs here, for those of us who'd like an idea of how this works but aren't in the weeds like the Containerization engineers?

3 Likes

Yes, the container project (GitHub - apple/container: A tool for creating and running Linux containers using lightweight virtual machines on a Mac. It is written in Swift, and optimized for Apple silicon.) and the containerization library it's built with (GitHub - apple/containerization: Containerization is a Swift package for running Linux containers on macOS.) work with the standardized OCI image format. So it's perfectly valid to build an image with docker/podman/other container tool and run a container based on this image with either the library or the container tool.