Your first Firecracker microVM, one API call at a time
By Origin Clouds Engineering, Platform team
The first surprise for most teams is that Firecracker is not configured like QEMU. You start the process with almost nothing, and then describe the VM over an HTTP API served on a Unix socket. Once that clicks, the design makes sense: an orchestrator can drive thousands of these without parsing command lines.
Before you start
- A Linux host with KVM, and read/write access to /dev/kvm for your user
- A Firecracker release binary for your architecture
- An uncompressed guest kernel (vmlinux) and an ext4 root filesystem image
[ -r /dev/kvm ] && [ -w /dev/kvm ] && echo "KVM ok" || echo "no KVM access"The Firecracker getting-started guide links to a kernel and rootfs that are known to work. Use those first, and build your own images only after you have a VM booting.
Start the VMM
rm -f /tmp/fc.sock
./firecracker --api-sock /tmp/fc.sockLeave that running in one terminal. It is now waiting for instructions; there is no VM yet.
Describe the VM
Three calls set the kernel, the root drive and the machine size. Each one is idempotent until the VM starts, so an orchestrator can retry safely.
SOCK=/tmp/fc.sock
api() { curl -s --unix-socket $SOCK -X PUT "http://localhost/$1" -H 'Content-Type: application/json' -d "$2"; }
api boot-source '{"kernel_image_path":"./vmlinux","boot_args":"console=ttyS0 reboot=k panic=1 pci=off"}'
api drives/rootfs '{"drive_id":"rootfs","path_on_host":"./rootfs.ext4","is_root_device":true,"is_read_only":false}'
api machine-config '{"vcpu_count":2,"mem_size_mib":1024}'Boot it
api actions '{"action_type":"InstanceStart"}'Switch back to the first terminal and you'll see the guest's serial console. On a warm host with a small kernel, that typically takes well under a second.
Prefer a file? Use --config-file
For experiments and CI, the same settings can live in one JSON file, and Firecracker will boot straight from it without the API.
./firecracker --no-api --config-file vm.jsonWhat changes in production
- Run every VM under the jailer, which drops privileges, chroots and places the process in its own cgroups and namespaces
- Keep the default seccomp filters on; they are part of the security model, not an optional extra
- Give each VM its own tap device and decide early how you will allocate IPs and MACs
- Rate-limit disk and network per VM so one tenant can't starve the host
Firecracker deliberately has no BIOS, no PCI by default and no USB. If a workload needs any of those, that's a sign it belongs on QEMU/KVM instead.
Running this in production?
We help teams design, harden and tune platforms like this one.
Talk to an engineer
Origin Clouds