Overview
AKraftfile is a YAML configuration file that defines how to build and package your Unikraft application. It serves as the main entry point for the kraft CLI tool.
Basic Structure
Every Kraftfile must specify a spec version and at minimum a runtime or kernel:Kraftfile
Specification Version
Thespec field defines the Kraftfile format version:
v0.6(Latest, recommended)v0.5
Runtime Configuration
Using Pre-built Runtimes
Specify a pre-built runtime from the Unikraft catalog:Using Full URLs
Reference runtimes using complete URLs:Version Pinning
Pin specific versions for reproducible builds:Kernel Configuration
For advanced use cases, specify a custom kernel instead of a runtime:Root Filesystem
Therootfs field defines your application’s filesystem.
Using Dockerfile
Reference an existing Dockerfile:Inline Dockerfile
Define the filesystem build inline:Multi-stage Builds
Use multi-stage Dockerfiles for smaller images:Using Pre-built Images
Reference container images directly:Command Configuration
Specify the command to run when the unikernel starts:Array Format (Recommended)
String Format
With Working Directory
Build Targets
Define multiple build targets for different architectures and platforms:Target Fields
name: Target identifier (required)architecture: CPU architecture (x86_64, arm64, arm)platform: Hypervisor/platform (qemu, kvm, xen)
Template Configuration
Use templates for common application patterns:Environment Variables
Set environment variables for your application:Volumes and Mounts
Configure volume mounts for persistent storage:Network Configuration
Configure network settings:Library Configuration
For make-based builds, specify external libraries:Complete Examples
Simple Hello World (C)
Kraftfile
Go Web Server
Kraftfile
Python Flask Application
Kraftfile
Rust Application with Dependencies
Kraftfile
Node.js with Nginx Frontend
Kraftfile
Multi-Architecture Build
Kraftfile
Advanced Configuration
Custom Build Arguments
Pass build arguments to Dockerfile:Resource Constraints
Set resource limits:Security Options
Kraftfile Best Practices
1. Use Multi-stage Builds
Keep images small by using multi-stage builds:2. Pin Versions
Always pin specific versions for reproducibility:3. Minimize Layers
Combine commands to reduce image size:4. Use .dockerignore
Create.dockerignore to exclude unnecessary files:
5. Environment-Specific Configuration
Use environment variables for configuration:Schema Validation
Validate your Kraftfile syntax:- Valid YAML syntax
- Correct field names
- Required fields
- Type validation
Troubleshooting
Common Errors
Error: “unknown field ‘xyz’”Debugging Kraftfiles
Enable verbose output:Next Steps
Building Applications
Learn how to build unikernels from your Kraftfile
Configuration
Explore advanced Kconfig options
Running Unikernels
Deploy and run your configured unikernels
Examples
Browse example Kraftfiles in the community catalog