Use FirecrackerVM / firecracker-containerd as an isolation wrapper around Docker containers.
Running both Ubuntu 22.04 (Jammy Jellyfish) from a live USB disk and Debian 12 (bookworm) in VirtualBox on a Mac (and then a live USB as well). Initially started with Ubuntu because I'm more familiar with it but the firecracker-containerd quickstart is Debian-oriented so I may be swimming against the tide with Ubuntu.
- Debian 12 (live USB) - skip build
- Debian 11 (live USB)
- Debian 12 (live USB)
- Debian (in VirtualBox)
- Random
- Ubuntu (live USB)
- References
sudo apt update
git clone https://github.com/davidkuster/firecracker-containerd-experiment
./scripts/debian/fc-setup.sh
./scripts/debian/fc-install-skip-build.sh
sudo firecracker-containerd --config /etc/firecracker-containerd/config.toml
- Open new tab, then
su - $(whoami)
andgroups
- ensuredocker
is in the list - In new tab:
sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \ image pull \ --snapshotter devmapper \ docker.io/library/debian:latest
- Again in new tab:
sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \ run \ --snapshotter devmapper \ --runtime aws.firecracker \ --rm --tty --net-host \ docker.io/library/debian:latest \ test
- In the logs of the first tab where
firecracker-containerd
is running, it has these errors:DEBU[2024-07-17T03:40:30.735327018Z] attempt=194 error="temporary vsock dial failure: vsock ack message failure: failed to read \"OK <port>\" within 1s: EOF" runtime=aws.firecracker vmID=3b1c16eb-9dc6-46ac-903c-7db5107d8b2c DEBU[2024-07-17T03:40:30.805937712Z] sending signal 9 to 6793 jailer=noop runtime=aws.firecracker vmID=3b1c16eb-9dc6-46ac-903c-7db5107d8b2c ERRO[2024-07-17T03:40:30.806149695Z] failed to create VM error="failed to dial the VM over vsock: context deadline exceeded" runtime=aws.firecracker vmID=3b1c16eb-9dc6-46ac-903c-7db5107d8b2c DEBU[2024-07-17T03:40:30.806665716Z] stopVMM(): sending sigterm to firecracker runtime=aws.firecracker ERRO[2024-07-17T03:40:30.807201288Z] shim CreateVM returned error error="rpc error: code = DeadlineExceeded desc = VM \"3b1c16eb-9dc6-46ac-903c-7db5107d8b2c\" didn't start within 20s: failed to dial the VM over vsock: context deadline exceeded" ERRO[2024-07-17T03:40:30.810482731Z] copy shim log error="read /proc/self/fd/12: file already closed" namespace=default DEBU[2024-07-17T03:40:30.810779988Z] shim has been terminated error="signal: killed" vmID=3b1c16eb-9dc6-46ac-903c-7db5107d8b2c
- See full log output in logs/fc.log (running above command with
> logs/fc.log 2>&1
)
Starting fresh from a Debian 11 (bullseye) live USB.
Note wifi does not work by default with Debian 11. I dug out a network cable.
sudo apt update
sudo apt install git
git clone https://github.com/davidkuster/firecracker-containerd-experiment
scripts/debian/fc-setup.sh
(source)sudo scripts/debian/fc-install.sh
(source)- Wait for it to run out of disk space, then run
sudo scripts/docker-fix-disk-space.sh
(source) - Rerun
sudo scripts/debian/fc-install.sh
- same error
docker run --rm \ --security-opt=apparmor=unconfined \ --volume /home/user/firecracker-containerd/tools/image-builder:/src \ --volume /src/tmp \ --cap-add=sys_admin \ --cap-add=sys_chroot \ --env=DEBMIRROR \ fc-image-builder:latest all mkdir tmp/rootfs debootstrap --variant=minbase --include=udev,systemd,systemd-sysv,procps,libseccomp2,haveged bullseye "tmp/rootfs" http://deb.debian.org/debian /usr/sbin/debootstrap: 1723: cannot create /src/tmp/rootfs/test-dev-null: Permission denied E: Cannot install into target '/src/tmp/rootfs' mounted with noexec or nodev make: *** [Makefile:81: debootstrap_stamp] Error 1 make[1]: *** [Makefile:119: all-in-docker] Error 2 make[1]: Leaving directory '/root/firecracker-containerd/tools/image-builder' make: *** [Makefile:166: image] Error 2
- same error
Starting fresh from a Debian 12 (bookworm) live USB.
sudo apt-get update
- Clone this repo (git is already installed)
git clone https://github.com/davidkuster/firecracker-containerd-experiment
- Follow the firecracker-containerd getting started instructions, included in this repo as slightly tweaked scripts:
scripts/debian/fc-setup.sh
(source)scripts/docker-fix-disk-space.sh
(source) (preemptively fix Docker disk space issues)sudo scripts/debian/fc-install.sh
(source)- note the
sudo
here so that the Docker commands will work - current status
- this command in the
tools/image-builder/Makefile
returns an error:
debootstrap --variant=minbase --include=udev,systemd,systemd-sysv,procps,libseccomp2,haveged bullseye "tmp/rootfs" http://deb.debian.org/debian /usr/sbin/debootstrap: 1723: cannot create /src/tmp/rootfs/test-dev-null: Permission denied E: Cannot install into target '/src/tmp/rootfs' mounted with noexec or nodev make: *** [Makefile:81: debootstrap_stamp] Error 1 make[1]: *** [Makefile:119: all-in-docker] Error 2 make[1]: Leaving directory '/root/firecracker-containerd/tools/image-builder' make: *** [Makefile:166: image] Error 2
- this command in the
- note the
Note: this is the same error as in the Ubuntu attempt below.
TL;DR - this isn't working for me, due to virtualization issues. VirtualBox doc indicates this should work:
Oracle VM VirtualBox supports nested virtualization. This feature enables the passthrough of hardware virtualization functions to the guest VM. That means that you can install a hypervisor, such as Oracle VM VirtualBox, Oracle VM Server or KVM, on an Oracle VM VirtualBox guest. You can then create and run VMs within the guest VM.
However, when running kvm-ok it's reporting KVM virtualization is not available, even though the Intel processor in my Mac should support it.
Starting from a fresh VM.
-
Create VM in VirtualBox, using debian-12.5.0-amd64-DVD-1.iso (and validate the sha)
- change login to
debian
/debian
- select
Guest Additions
- allocate 8GB RAM, 4 CPUs
- set disk space to 50GB (but don't pre-allocate)
- change login to
-
Add user to sudoers
sudo visudo -f /etc/sudoers
orsu -
thenvisudo -f /etc/sudoers
- add
<user> ALL=(ALL:ALL) ALL
under the similar line forroot
-
Fix sources list for apt/apt-get
vi /etc/apt/sources.list
- Comment out the exising line:
# deb cdrom ...
- Add the example values here:
deb http://deb.debian.org/debian bookworm main non-free-firmware deb-src http://deb.debian.org/debian bookworm main non-free-firmware deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware deb http://deb.debian.org/debian bookworm-updates main non-free-firmware deb-src http://deb.debian.org/debian bookworm-updates main non-free-firmware
-
Set nested virtualization config in VirtualBox
- Shut down VM
VBoxManage modifyvm <vm-name> --nested-hw-virt on
- Restart VM
-
Verify KVM virtualization is available via any of:
lsmod | grep kvm
egrep "svm|vmx" /proc/cpuinfo
sudo kvm-ok
(install viasudo apt-get install cpu-checker
)
-
Manually install git (to clone this repo with the scripts)
sudo apt-get install -y git
-
Clone this repo
git clone https://github.com/davidkuster/firecracker-containerd-experiment
-
Run these scripts (slightly tweaked versions of the firecracker-containerd getting started instructions):
scripts/debian/fc-setup.sh
(source)scripts/docker-fix-disk-space.sh
(source) (preemptively fix Docker disk space issues)scripts/debian/fc-install.sh
(source)- this command especially will dump out a ton of logs
- it may complain
device-mapper: reload iotcl on fc-dev-thinpool failed: No such device or address
but this can be ignored if thefirecracker-runtime.json
output is shown in the next step
-
Start firecracker-containerd (getting started step 5)
sudo firecracker-containerd --config /etc/firecracker-containerd/config.toml
-
In another window run the commands in getting started step 6
sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \ image pull \ --snapshotter devmapper \ docker.io/library/debian:latest
This is successful for me.
sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \ run \ --snapshotter devmapper \ --runtime aws.firecracker \ --rm --tty --net-host \ docker.io/library/debian:latest \ test
This fails:
ctr: failed to start shim: start failed: aws.firecracker: unexpected error from CreateVM: rpc error: code = Unknown desc = failed to create VM: failed to start the VM: Put "http://localhost/actions": EOF: exit status 1: unknown
See logs section for a (so far unsuccessful) attempt to get more information about this error.
I've now had DNS fail twice on me after running the firecracker-ctr ... test
command more than once. I'm able to ping IPs but have to replace my local nameserver config in /etc/resolve.conf
with those from Google:
# Generated by NetworkManager
search attlocal.net
#nameserver 192.168.1.254
nameserver 8.8.8.8
nameserver 8.8.4.4
Weird.
Trying to see in the logs what's happening with the unknown error above. But it looks like while log_fifo
is still in the doc that's been renamed to log_path
in the code. Attempting this config in /etc/containerd/firecracker-runtime.json
but unable to get it to create a log file so far:
{
"firecracker_binary_path": "/usr/local/bin/firecracker",
"cpu_template": "T2",
"log_path": "/tmp/fc-logs.fifo",
"level": "Debug",
"show_level": true,
"metrics_path": "/tmp/fc-metrics.fifo",
"kernel_args": "console=ttyS0 noapic reboot=k panic=1 pci=off nomodules ro systemd.unified_cgroup_hierarchy=0 systemd.journald.forward_to_console systemd.unit=firecracker.target init=/sbin/overlay-init",
"default_network_interfaces": [{
"CNIConfig": {
"NetworkName": "fcnet",
"InterfaceName": "veth0"
}
}]
}
But, it's also been this way in Firecracker since 5 Aug 2020 with the v0.22.0 release. Is the firecracker-containerd quickstart that out of date?
Starting fresh from an Ubuntu 22.04 (Jammy Jellyfish) live USB.
sudo apt-get update
- Manually install git (to clone this repo with the scripts)
sudo apt-get install -y git
- Clone this repo
git clone https://github.com/davidkuster/firecracker-containerd-experiment
- Follow the firecracker-containerd getting started instructions, included in this repo as slightly tweaked scripts:
scripts/ubuntu/fc-setup.sh
(source)scripts/docker-fix-disk-space.sh
(source) (preemptively fix Docker disk space issues)sudo scripts/ubuntu/fc-install.sh
(source)- note the
sudo
here so that the Docker commands will work - current status
- this command in the
tools/image-builder/Makefile
returns an error:
debootstrap --variant=minbase --include=udev,systemd,systemd-sysv,procps,libseccomp2,haveged bullseye "tmp/rootfs" http://deb.debian.org/debian /usr/sbin/debootstrap: 1723: cannot create /src/tmp/rootfs/test-dev-null: Permission denied E: Cannot install into target '/src/tmp/rootfs' mounted with noexec or nodev make: *** [Makefile:81: debootstrap_stamp] Error 1 make[1]: *** [Makefile:119: all-in-docker] Error 2 make[1]: Leaving directory '/root/firecracker-containerd/tools/image-builder' make: *** [Makefile:166: image] Error 2
- this command in the
- note the
- firecracker-containerd quickstart
- firecracker-containerd getting started
- Getting Started with Firecracker
- firecracker-containerd issue on quickstart and Ubuntu