feat: add native Linux mode (vmType=native) — bypass Lima/QEMU on Linux hosts#1565
Open
architectureman wants to merge 3 commits into
Open
feat: add native Linux mode (vmType=native) — bypass Lima/QEMU on Linux hosts#1565architectureman wants to merge 3 commits into
architectureman wants to merge 3 commits into
Conversation
…ux hosts Add vmType 'native' that runs container runtimes (Docker, containerd, Incus, K3s) directly on the Linux host without any virtualization layer. Key changes: - New environment/vm/native/ package: VM interface via direct host execution - Config validation: native type auto-detected on Linux, skips VM-specific checks - App factory: NewWithVMType() solves config-before-VM-creation ordering - model/guest.go: centralized newGuest() replaces 13x hardcoded lima.New() - Command guards: skip limautil calls when in native mode - Docker daemon: fallback from host.lima.internal to ip route for gateway IP - Docker context: use /var/run/docker.sock directly in native mode - K3s/Kubeconfig: use host IP and primary interface - Incus: guard DiskProvisioned/MountPoint for native - colima model: blocked in native mode (GPU passthrough requires krunkit VM) Tested: - Cross-compiled GOOS=linux GOARCH=amd64: OK - macOS regression GOOS=darwin GOARCH=arm64: OK - go vet: OK - E2E in Colima VM: start → status → stop → delete lifecycle verified
3aa48ef to
5107398
Compare
added 2 commits
April 30, 2026 10:56
- Add NativeInstances() to scan state files directly from filesystem - Modify Instances() to merge Lima + native instances with dedup - Gracefully handle missing limactl (return nil instead of error) - Fix currentRuntime() to fallback to config for native mode - Fix Teardown() to clean up state directory on delete - Add isSystemdActive() and getNativeIPAddress() helpers All 7 E2E tests pass on Ubuntu 24.04 VM: 1. List (empty) ✓ 2. Start (native docker) ✓ 3. List (running) ✓ 4. Status ✓ 5. JSON output ✓ 6. Delete ✓ 7. List (after delete) ✓
Ensures Linux users running VM-mode (Lima/QEMU) still see proper error messages if limactl encounters issues. Only suppresses the 'executable not found' case for native-only setups.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On Linux hosts, Colima currently creates a full Linux VM via Lima/QEMU even though the host itself is already running Linux. This adds unnecessary overhead in terms of CPU, memory, disk, and startup time. Many Linux users expect container runtimes to run natively — the same way Docker Desktop works on Linux.
This PR introduces
vmType: "native"which allows Colima on Linux to use the host's container runtime directly, eliminating the virtualization layer entirely while keeping the same Colima UX (profiles,colima start/stop/status/delete, Docker context management, Kubernetes provisioning, etc.).What's New
How It Works
A new
environment/vm/native/package implements theenvironment.VMinterface using direct host execution (os/exec) instead of SSH-based Lima commands:limactl shell ...(SSH)os/exec.Commandos.ReadFile/os.WriteFile~/.colima/.../docker.sock(forwarded)/var/run/docker.socklimautil.Instance()/proc/cpuinfo+syscall.Statfshost.lima.internalip route show defaultSafety Guarantees
--vm-type qemuon Linux if they prefer isolationlimautil.*calls are guarded withconf.VMType != "native"checkscolima model— intentionally blocked in native mode for the initial release (GPU passthrough setup differs from krunkit)Changes Summary
New files (7):
util/linux.go—Linux()detection helperenvironment/vm/native/{native,shell,file,config,hostinfo}.go— Full VM interface implementationmodel/guest.go— CentralizednewGuest()factory (replaces 13× hardcodedlima.New())Modified files (18):
environment/vm.go—DefaultVMType()returnsnativeon Linuxconfig/config.go—DriverLabel()returns"Native"config/configmanager/configmanager.go— Skip VM validations for nativeapp/app.go—NewWithVMType()factory + limautil guardscmd/{start,restart,clone,ssh-config,prune,util}.go— CLI integrationenvironment/container/docker/{daemon,context}.go— Socket + gateway fallbackenvironment/container/kubernetes/{k3s,kubeconfig}.go— IP address guardsenvironment/container/incus/incus.go— Disk provisioning guardmodel/{docker,ramalama,runner}.go—newGuest()migrationTesting
GOOS=linux GOARCH=amd64GOOS=darwin GOARCH=arm64go vet ./...start → status → stop → delete(in Colima VM)E2E Test Output (click to expand)
Use Cases
Dependencies
dockergroup (for Docker runtime)Future Work
colima modelsupport in native mode (NVIDIA Container Toolkit integration)environment/vm/native/package