From 2e93381de3c674d548c2852ec91151cee465d6d1 Mon Sep 17 00:00:00 2001 From: Aditya Ramani Date: Sun, 9 Nov 2025 20:54:59 -0800 Subject: [PATCH] Pull initfs from repository when running ctr-example (#391) Use the initial filesystem image from a remote repository when brining up the ctr-example --- examples/ctr-example/Makefile | 6 +----- examples/ctr-example/README.md | 1 + examples/ctr-example/Sources/ctr-example/main.swift | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/ctr-example/Makefile b/examples/ctr-example/Makefile index 2a1ea5fb..f79f220b 100644 --- a/examples/ctr-example/Makefile +++ b/examples/ctr-example/Makefile @@ -18,7 +18,7 @@ SWIFT = /usr/bin/swift .PHONY: all build clean run -all: containerization run +all: run build: $(SWIFT) build --configuration release @@ -39,10 +39,6 @@ debug: fmt: $(SWIFT) format --in-place --recursive Sources/ - -containerization: - $(MAKE) -C ../.. all - fetch-default-kernel: $(MAKE) -C ../.. fetch-default-kernel cp -L ../../.local/vmlinux ./vmlinux diff --git a/examples/ctr-example/README.md b/examples/ctr-example/README.md index 44df1e11..05873bca 100644 --- a/examples/ctr-example/README.md +++ b/examples/ctr-example/README.md @@ -24,6 +24,7 @@ After the build completes, the example will run. In your terminal you should see ``` Starting container example... +Fetching container initial filesystem... Creating container from docker.io/library/alpine:3.16... Starting container... / # diff --git a/examples/ctr-example/Sources/ctr-example/main.swift b/examples/ctr-example/Sources/ctr-example/main.swift index a32935f4..cf8df300 100644 --- a/examples/ctr-example/Sources/ctr-example/main.swift +++ b/examples/ctr-example/Sources/ctr-example/main.swift @@ -28,10 +28,12 @@ struct CtrExample { try current.setraw() defer { current.tryReset() } + let initfsReference = "ghcr.io/apple/containerization/vminit:0.13.0" + print("Fetching base container filesystem...") // Create container manager with file-based initfs var manager = try await ContainerManager( kernel: Kernel(path: URL(fileURLWithPath: "./vmlinux"), platform: .linuxArm), - initfsReference: "vminit:latest", + initfsReference: initfsReference, network: try ContainerManager.VmnetNetwork() )