docker-boot icon indicating copy to clipboard operation
docker-boot copied to clipboard

Like `execve`, but for userspace

docker-boot

https://github.com/purplesyringa/docker-boot/assets/16370781/0f2a24e1-7c5f-47a6-9730-479f853af25a

Like execve, but for userspace.

docker-boot replaces your current running system with an in-memory root filesystem constructed from a Docker image.

Example with GUI:

Dockerfile

FROM ubuntu
RUN apt update
RUN apt-get install -y software-properties-common && add-apt-repository ppa:mozillateam/ppa
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y sudo htop systemd sddm kde-plasma-desktop firefox-esr
RUN useradd --create-home --shell /bin/bash --groups sudo --password "$(perl -e "print crypt('cutie', 'sa');")" --user-group purplesyringa
RUN echo "InputMethod=" >/etc/sddm.conf
$ docker build . -t workstation
<...>

$ sudo docker-boot workstation /bin/systemd
<The host system is shut down, Ubuntu with lightdm/KDE starts>

Example without GUI:

Dockerfile

$ sudo docker-boot ubuntu /bin/bash -c "mount -t proc proc proc; mount -t sysfs sys sys; exec bash -i"
<The host system is shut down, Ubuntu starts in single-user mode>

(Or make systemd mount the filesystems for you if you're feeling adventurous.)

Building

Just do make.

You're going to need docker, swapoff, tar, and dd installed.

Why?

  1. I'm a Nix contrarian, so naturally I wanted something to be to Docker like NixOS is to Nix. docker-boot fills this niche.
  2. Injecting into init is based, I've always wanted to do that; this project is my excuse.
  3. If you need to move partitions on your boot disk, you probably want to run a system off RAM. This is typically accomplished by creating a tmpfs, debootstraping an OS into it, pivot_rooting and killing services that use the real disk. That's a bit ridiculous of a manual; this project attempts to reduce the gap.