Add support for WSL Containers runtime#194
Conversation
…ge cache Introduces the wslc CLI orchestrator and wires it through the container/network orchestrator abstractions and runtime flag. Adds a content-addressed derived-image cache that skips rebuilds when the base image content and image layers are unchanged, keyed on the base image's content ID rather than its (possibly mutable) tag.
|
Hey @antsok, thanks for the PR; we're actively working with the WSL team to close some of the gaps in Given that we expect most of the blocking issues to be resolved soon, we'd prefer not to make any changes to the container controller or shared orchestrator definitions to workaround the current limitations just to back out those changes in a month or two. A few of the workarounds such as delaying file copy operations would be fundamentally incompatible with some Aspire usage anyway as we specifically use the feature to copy files that need to be in place before we run the containers. If you're still eager to get initial |
|
Hi @danegsta , I am happy to wait if the WSL team is adding cp soon. My PR works around certificate problem by layering the images with generated certs. cp is much cleaner :) |
Fixes #179 (Iteration 1); to be followed after microsoft/WSL#40835 is completed.
Add
wslccontainer runtime supportSummary
Adds a new
wslccontainer runtime to DCP, alongside the existingdockerandpodmanruntimes.wslcis the WSL container CLI (buildkit backend) that runs containers on Windows without Docker Desktop. This PR plumbs a fullwslcorchestrator through DCP's container/network abstractions and introduces a content-addressed derived-image cache so that per-container customization layers (config files, certificates) are baked once and reused across runs instead of being rebuilt every time.Motivation
wslc), with no dependency on Docker Desktop.wslchas a session-wide volume-mount limit and nocontainer cpprimitive, so the existing "copy files into a created container" flow does not translate directly. This PR adapts DCP's file-injection and image-customization model to those constraints.What's included
New
wslcorchestratorinternal/wslc/cli_orchestrator.go— fullContainerOrchestrator/NetworkOrchestratorimplementation driving thewslcCLI: container/network/volume/image lifecycle, image pull/inspect/build, log streaming, exec, and terminal (PTY) support.tar) mapped onto DCP's shared sentinel errors (ErrNotFound,ErrAlreadyExists).--container-runtimeflag (docker,podman,wslc).Content-addressed derived-image cache
When a container needs extra layers (e.g. injected config files or dev certificates), DCP now builds a derived image tagged as:
The cache key folds in the base image's immutable content ID (not its tag), so mutable tags like
latestare handled correctly — a registry-side move oflatestto new content yields a different key and triggers a rebuild.Before building, the controller probes for the derived tag and reuses it on a hit, skipping
wslc buildentirely. This keepswslc's session-wide build-context/volume-mount usage bounded across repeated runs.Tar layer generation is deterministic (fixed mod-times, sorted paths) so identical inputs always produce the same digest.
Orchestrator abstraction changes
CreateFilesgainsCreateFilesRequiresRunningContainer()— runtimes that inject files by exec-ingtarinside the container (wslc) returntrue, so the controller defers the copy until the container is running; Docker/Podman (cp) returnfalse.CreateContainerOptionsgainsCreationNetworks(per-network aliases attached at creation time) for runtimes that can only attach networks at creation.BuildCreateFilesTar(...)produces an in-memory tar (usable both as a container file-copy payload and as an image layer).Files changed
internal/wslc/cli_orchestrator.go,internal/wslc/cli_orchestrator_test.gointernal/containers/flags/container_runtime.go,internal/containers/runtimes/runtime.gointernal/containers/container_orchestrator.go,internal/containers/containers_common.go(+ test),internal/containers/network_orchestrator.gocontrollers/container_controller.go,controllers/container_image_layer_cache_test.gointernal/docker/cli_orchestrator.go,internal/podman/cli_orchestrator.gointernal/testutil/ctrlutil/test_container_orchestrator.goMakefile(PowerShellSHELLFLAGSfix for Windows)Testing
wslcorchestrator (CLI argument construction, error mapping, parsing).go build ./...,make lint(0 issues), and package tests pass.wslc, confirming cache hits across repeated runs (zero rebuilds when inputs are unchanged) and correct behavior across stop/restart.Notes for reviewers
PullPolicyAlways, the base image is re-pulled before its content ID is read (so registry-sidelatestmoves are detected); with the default/Neverpolicies, the locally present base content ID is used, matching normalcreatesemantics.api/v1(the regeneratedzz_generated.*files have no content delta).