iximiuz / docker-to-linux

Make bootable Linux disk image (ab)using Docker
https://iximiuz.com/en/posts/from-docker-container-to-bootable-linux-disk-image/
669 stars 93 forks source link

Practical use: versionable docker based linux distribution #20

Closed ljleb closed 2 years ago

ljleb commented 3 years ago

I want to make an OS that doesn't require any maintenance, because I believe system maintenance sucks.

I'm currently on XUbuntu 16.04 and I'm about to switch distribution. I have to wipe out all of my system data (yes, after a backup) because there's really old building-from-source clones, executables and whatnots on my drive, and I don't know where to begin the cleanup. Wouldn't it be great if I never had to cleanup or upgrade my distribution in the first place?

Maybe I'm daydreaming, but in order to achieve that, I've been thinking of using docker as a "package manager" for applications. Custom Dockerfiles and application data would be stored somewhere in the file system tree, where application binaries would only reside within docker images and containers. This idea makes me think about exo kernels, although exo kernels are lower-level and can technically support Windows and Linux applications concurrently without a virtual layer.

Now, about the "versionable" part in the title: backups can come in quite handy sometimes, and I like git for it's ability to roll back any change and keep an history of what happened in a repository. Wouldn't it be nice if I could version my system configuration and simply create a new bootable image in one line when my computer dies? To achieve this, I would store Dockerfile / docker-compose.yml files in a repository, along with their configuration files. Once I succeed to install an application in a docker image, I commit the image configuration to a new folder in my repository. If I ever have to run the app somewhere else, it's simple: just clone, build and run; perhaps even just pull from Docker Hub. If I ever want to completely remove an application from my disk, I can also simply do that with docker rmi.

Another advantage of this idea is that distribution specific packages could be installed without having to bring potentially incompatible configuration on my system. For example, it would be possible to use any pacman package along with any apt-get package, effortlessly.

However, how can I be sure that my system configuration never gets out of hand? For me, this is where docker-to-linux comes into play. It allows me to store the fundamental OS configuration as a dockerfile. It gives me full control over what's in my system, regardless of the depth of my knowledge about Unix-like operating systems, basic tools, bootloaders, partitions, initramfs, bios, assembly, etc.

Yes, I might encounter issues along this journey. For instance, docker images usually take a lot of space. There might not be a lot of images on Docker Hub that fit exactly my use case, forcing me to write a big bunch of custom docker files (and this looks like maintenance to me). Maybe something exists that already solves the issues mentioned above, and I just don't know about it. So I can't tell whether the advantages of this idea over traditional system maintenance would be worth it.

ljleb commented 2 years ago

A year later, I found that I had to look a bit further online to find what I was looking for. I wasn't daydreaming, although maybe I didn't explain my ideas as well as I'd have liked to.

NixOS is actually exactly what I had been looking for. Just leaving this here in case someone else comes across this thread.

iximiuz commented 2 years ago

I might have missed this issue a year ago, but I just have thoroughly enjoyed the read! Indeed, NixOS sounds like a pretty close match to your requirements.

Interestingly, I probably achieved a somewhat similar effect by treating all my environments as ephemeral and using a VM (with scripted provisioning) per project. And my host OS has very few things installed, so re-creating the setup is relatively trivial (I recently moved from a 7 yo laptop to a new one in under an hour).