Few months ago I wrote a tutorial about creating Linux distribution consisting of just busybox as its userspace. In the meantime I worked a bit with docker and it sounded like nice next step in learning docker to automate the process of creating Linux distribution using it. As a result, today I present Linux distribution built with docker and based on my previous tutorial. I called it busy-linux due to it consisting of only busybox at the moment. My plan is to develop it further, most likely for private purposes only, so there might not be much happening in the project, but for sure I want to create dynamically linked variant in the near future, as this is what my use case requires. In the meantime feel free to try it yourself.
Installation is as simple as copying binary that is available on Github to your EFI partition. If you do not have EFI partition yet, or want to set up new one on other device, I already described the process in my previous article on the matter: Busybox-based Linux distro from scratch (section
Preparing new EFI system partition). As soon as you do that, you should already see new entry in your EFI boot manager, or if using default one, you may have to add it manually, which is as simple as:
efibootmgr --create --disk /dev/sdz --part 1 --loader /EFI/linux/linux.efi --label "My Own Linux Distro" --verbose
This is also in mentioned tutorial.
Some people prefer to build things from source, instead of trusting third parties that this third party did things honestly. If you are of those, building with docker is extremely easy. What is more, this process should work all the time, once Dockerfile has been written once. In case of busy-linux, it is just matter of cloning one-file repo from here and calling usual
docker build command with arguments of your preference, like tag name:
docker build -t busy-dev
At the end, you should get an image with EFI binary inside, which can be extracted after running the container with:
docker run --detach --name busy-dev -it busy-linux
With container running simple
docker cp is enough to have Linux outside:
docker cp busy-dev:/root/busy-linux.efi ./
Afterwards, you can go back to installation section.
Comparing to manually following steps from my previous tutorial, this method is really fast. What makes it even faster is that docker has built-in caching mechanism, which rebuilds only parts of Dockerfile. In this case I used another feature of modern docker, which is multistage build. Result of this is the fact that only part of the modified stage is rebuilt after any change and obviously all stages that depends on this one. The result is that only small fraction of whole container is built from scratch. Side effect is that final container is reduced in size it requires, but in this case, I am not using this fact in any way, as I am not publishing my container to docker hub, or any other registry.