Stevedore and docker on Windows — setup fixes and service recovery#
Post-install fixes for a Stevedore host, plus the registry-auth, networking and service-recovery problems that are properties of docker on Windows rather than of this repo’s chain.
For an ordered bring-up of a brand-new host start at
windows-host-setup.md — this page is the reference it
points into.
Stevedore disk inventory#
From an elevated PowerShell 7 session, run the read-only inventory before deciding what can be reclaimed:
.\windows\scripts\host\Get-StevedoreInventory.ps1
It reports filesystem free space, BuildKit disk usage, and the images and
containers in the BuildKit containerd namespace. nerdctl needs elevation on
the reference host. Use -StevedoreNamespace, -BuildkitAddress,
-ContainerdAddress, -NerdctlPath and -BuildctlPath for a different host;
the defaults point to the Stevedore installation and named pipes. A failed probe
returns a nonzero exit code, so a partial inventory is not a complete report.
Shared layers can remain pinned by image tags, while pruning build cache can
make later builds slower. Cleanup targets use GiB; the canonical script rounds up
to decimal MB for BuildKit. Its exit code alone does not prove enough space is free. Review the store GC guidance
and the sanctioned cleanup tool before
removing anything.
Delegated maintenance and new hosts#
The versioned Install-StevedoreMaintenance.ps1 installs two fixed SYSTEM
tasks under \ANTfrastructureMaintenanceV2\. An administrator approves the
installation once; the selected ordinary Windows user can then request a
preview or bounded cleanup without another UAC prompt. Agents may use this
installed policy without asking for every tag again. This does not give the
agent a general administrator token or let it submit commands to SYSTEM.
Retention policy#
The fixed policy is intentionally narrower than system prune:
Only the
buildkitnamespace is inspected. Every native query must succeed; unknown identities, warnings or state refuse the entire action. The inventory reads nerdctl’s raw JSONNameand manifestID, then inspects each distinct manifest separately to bind its configuration ID. Display-table repository/tag reconstruction loses digest-qualified names; configuration IDs are not manifest selectors. Raw names and both identities remain in the preservation receipt.A completed media-branch tag may retire only when its corresponding merged Media tag exists and no retained container references its configuration or manifest ID. The seven allowed stage names are
windows-media-core-onnx,windows-media-core-ffmpeg,windows-media-core-opencv,windows-media-core-hailo,windows-media-core,windows-media-litertandwindows-media-tvm, underlocal/kataglyphis:bk-, with the existing CPU, NVIDIA/ROCm and ARM64 suffixes. These complete intermediate images are not archived; rebuilding them can take hours. Existence of a merged image is a retention condition, not whole-product or device acceptance.Only a stopped container carrying
org.kataglyphis.antfrastructure.disposable=truemay retire. Our diagnostic callers should add that label when creating an intentionally disposable container. Legacy unmarked containers remain protected. The command does not force removal and does not delete volumes or bind-mounted host data. nerdctl can return an emptyState.Statuswhen no current task exists. Accept that representation only with typed falseRunning,PausedandRestarting, typed zeroPid/ExitCodeand empty stringError/StartedAt/FinishedAt. Derivecreatedfor selection without changing the raw inspection. This proves no current task in the successful quiet query, not that it never ran. Both delegated inventory and the canonical per-removal read refuse native stderr; otherwise a failed task lookup can resemble task absence.Current Final/Torch/Media, SDK/toolchain/base tags, unrelated tags and compiler-cache mounts remain protected. Aliases and full before/after image identities are compared; an in-use or unknown cache record refuses cleanup.
Filesystem cleanup is not part of this policy. Regular cache pruning uses only the canonical
Clear-DiskSpace.ps1 -StevedoreOnly -RegularCache, with the existing 100-GiB free-space target and decimal-MB conversion. There is no--all, service restart, containerd restart, force-stop or build cancellation.
InspectBuildStorage only reports. ReclaimBuildStorage applies this exact
policy when below the target. When the target is already met, or no eligible
images, containers or private regular cache remain, it records a no-op rather
than repeating an exhausted prune. It measures actual free bytes afterwards;
exit zero means maintenance completed, not that 100 GiB became available.
The tasks have no timer or low-space watcher. An agent can request them before the next build. Existing BuildKit GC is separate. Idle checks are observations, not a global engine transaction: coordinate other sessions, retain the per-operation checks, and never run maintenance beside a build.
One-time setup on each host#
Finish Windows host bring-up, including Stevedore,
BuildKit GC, CNI and endpoints. Use PowerShell 7 and this checkout; the installer
derives the user SID, Windows directories, trusted tools and runtime locally.
It copies a protected, hashed payload/runtime under
C:\Program Files\ANTfrastructure Maintenance v2 on a normal Windows install.
It never schedules a file directly from the writable checkout. No package or
credential download is needed.
First inspect the installation plan in an ordinary shell:
pwsh -NoProfile -File .\windows\scripts\host\Install-StevedoreMaintenance.ps1
Then run once from Administrator PowerShell 7:
pwsh -NoProfile -File .\windows\scripts\host\Install-StevedoreMaintenance.ps1 -Apply
-ReaderSid selects another specific local/domain/Entra user if setup runs
under a different administrator account. -StoreRoot must match the existing
BuildKit store on a nondefault host; it only selects the volume to measure and
does not move any store. Tool paths use the local Program Files directory;
the bounded tasks use the standard local containerd/BuildKit pipes.
-ExpectedBundleSha256 can seal a reviewed source payload. A different or
partial installation refuses replacement; revoke and archive it first.
Setup creates disabled tasks, verifies their fixed SYSTEM principal, action, ACL and zero triggers, and only then enables them. The caller receives read/execute rights. Files, tool hashes, runtime and task configuration remain protected from the ordinary user. Setup itself starts no cleanup.
Ordinary-user operation and logs#
# Preview only; the privileged read uses its separate fixed task.
pwsh -NoProfile -File .\windows\scripts\host\Invoke-StevedoreMaintenance.ps1 -Apply:$false
# Apply the already approved retention policy.
pwsh -NoProfile -File .\windows\scripts\host\Invoke-StevedoreMaintenance.ps1 -Apply
# Read both task states and their latest receipts without starting a task.
pwsh -NoProfile -File .\windows\scripts\host\Invoke-StevedoreMaintenance.ps1 -Status
The client waits up to 300 seconds by default. Exit 2 means submitted but not
completed; it does not stop the worker. Use -Status and the protected logs,
not a second submission. -WaitSeconds changes only this client wait and is
never forwarded as a task argument. Operational maintenance has no timeout
that kills a native prune. Tasks ignore overlapping instances, use a shared
file lock and refuse another active v2 or legacy maintenance task.
Each run has a fresh directory under the installation’s logs\, with a full
transcript, native stdout/stderr, the plan, before/after identities and
result.json. latest-preview.json and latest.json point to the latest
respective result. Accept completion only for the returned task-instance GUID
and a run started after submission, with worker and scheduler raw exits both
zero, no remaining instance and verified preservation. target_met is a
separate observation. Recheck the next build’s unchanged disk floor yourself.
No source/image publication or GPU inference is proved by maintenance.
The SYSTEM worker locates its hidden instance through
TaskService.GetRunningTasks(1), requiring exactly one matching task path and a
nonempty GUID. RegisteredTask.GetInstances(0) is security-filtered and alone
did not expose the actual hidden SYSTEM run on the reference host. Completion
also requires scheduler state Ready; queued, running or unknown tasks refuse
overlap and revocation even when instance enumeration returns zero. Keep the
documented zero flag for GetInstances; one is the hidden-task flag only on
GetRunningTasks. See Microsoft’s running-task API
and instance enumeration.
First verify preview and Apply from a genuinely non-elevated shell on the host. The tests use fake daemons/tasks and cover selectors, refusal paths and mutations; they do not prove another machine’s ACLs, UAC, daemon layout or physical space gain. Preserve an actual host acceptance receipt. Zero or a different number of cache mounts is supported; unknown is never treated as zero. A fresh-machine acceptance remains distinct from existing-host success.
Revocation, updates and the old pilot#
To revoke the delegation, use Administrator PowerShell 7:
pwsh -NoProfile -File .\windows\scripts\host\Remove-StevedoreMaintenance.ps1
pwsh -NoProfile -File .\windows\scripts\host\Remove-StevedoreMaintenance.ps1 -Apply
An active task refuses revocation. The script unregisters only the two fixed v2 tasks and archives the protected directory beside its old location; logs are retained and no container, image or store is touched. Reinstall after review when payload, tools or policy change. Do not make SYSTEM scripts or their configuration writable to avoid the administrator installation step.
The first reference-host v2 setup registered both tasks, then stopped before creating its disposable control: reconstructed image names failed lookup. Its first normal-user preview also stopped before inventory because the hidden worker could not identify its original instance. No v2 image/container removal ran. Regression controls and mutations cover these failures; the corrected protected installation still requires a fresh real preview and Apply receipt. The earlier successful cache-only pilot is separate evidence. For an update, archive/revoke the idle installation and reinstall the reviewed payload through the commands above, then repeat normal-user acceptance. Keep the old receipts; successful setup or synthetic tests alone do not prove the correction on a host.
The earlier local pilot under ignored logs/handoff/stevedore-auto-cleanup/
is historical and is not copied to another host. Its RegularCache and
IdleRecovery tasks are separate; v2 does not overwrite or expand them. Its
measured results and recovery permissions are single-host evidence, not
acceptance of this versioned installer or proof of universal reliability.
Stevedore Setup Fixes#
After installing Stevedore, apply these post-install fixes. They are the canonical source. Fixes 1 and 2 are for their symptom only (which symptom: windows-host-setup.md § A4); Fix 3 is for every host.
Fix 1: Remove stale Docker Desktop daemon.json#
If Docker Desktop was previously installed, its daemon config at C:\ProgramData\docker\config\daemon.json may specify a hosts pipe (docker_engine_windows) that conflicts with Stevedore’s docker_engine pipe. Remove it:
if (Test-Path "C:\ProgramData\docker\config\daemon.json") { Remove-Item "C:\ProgramData\docker\config\daemon.json" }
Fix 2: Change default runtime from hcsshim to runhcs#
Stevedore’s service defaults to the com.docker.hcsshim.v1 runtime, but only the io.containerd.runhcs.v1 shim binary (containerd-shim-runhcs-v1.exe) ships with Stevedore. Apply this only when docker build fails with runtime "com.docker.hcsshim.v1" binary not installed: the reference host runs without the flag. Update the service binary path:
sc config stevedore binPath="\"C:\Program Files\Stevedore\dockerd.exe\" --run-service --service-name stevedore --group docker-users --host npipe:////./pipe/dockerDesktopWindowsEngine --host npipe:////./pipe/docker_engine --containerd=npipe:////./pipe/containerd-containerd --default-runtime=io.containerd.runhcs.v1"
Then restart:
net stop stevedore /y
net start stevedore
Fix 3: Windows Defender exclusions for containerd data#
Add exclusions for the container stores (prevents hcsshim layer commit errors — hcsshim::ActivateLayer failed (0x20), and the hcs-temp sharing-violation flakes):
Add-MpPreference -ExclusionPath "C:\ProgramData\containerd"
Add-MpPreference -ExclusionPath "C:\ProgramData\buildkitd"
Add-MpPreference -ExclusionPath "C:\ProgramData\nerdctl"
Add-MpPreference -ExclusionPath "C:\temp"
That is the core. The full set, with the process exclusions, is
windows-host-setup.md § C4, and
windows\scripts\host\Sync-DefenderExclusions.ps1 applies it. A persistent
ActivateLayer 0x20 on an AMD Radeon host is not Defender: it is the RDNA4
layer lock in the FIRST CHECK box at the top of that page.
Fix 4: docker.exe vs nerdctl (historical — pre-CNI-conf state)#
Before the CNI nat conf was installed (2026-08-03), nerdctl build lacked
DNS resolution and nerdctl run failed outright on this host (failed to create default network: needs CNI plugin "nat" to be installed in CNI_PATH —
the conf, not the binary, was missing), so docker.exe was the only working
tool. Current state: with the CNI nat config installed in both forms
(0-containerd-nat.conflist, which nerdctl reads, and the .conf buildkitd
reads — windows-host-setup.md § A5) nerdctl works
from admin shells; builds go through
Build-Buildkit.ps1/buildctl on the preferred lane — Stevedore ships that
buildctl.exe too. Stevedore’s docker.exe needs no CNI plugin and survives as
the publish/inspect tool, but it is not a build lane: fifteen of the
seventeen windows/Dockerfile.* (2026-09-25) use BuildKit-only RUN --mount,
so a docker.exe build of Dockerfile.base dies at its first RUN with
“the –mount option requires BuildKit” (the classic driver itself was deleted on 2026-08-31 —
windows-host-setup.md § R3. There is no classic lane to
reach for).
& "$env:ProgramFiles\Stevedore\bin\docker.exe" load -i out\bk-winamd64.tar # a -FinalTar export
& "$env:ProgramFiles\Stevedore\bin\docker.exe" image inspect local/kataglyphis:winamd64
Docker on Windows: registry auth, networking, service recovery#
Traps that are specific to running the Docker CLI/daemon on a Windows host, as opposed to the BuildKit/containerd lane above.
--password-stdin does not work — ghcr.io login#
The documented login form silently fails on Windows:
# does NOT work here
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
Two ways through. First, the credential helper is often the real culprit — open
$env:USERPROFILE\.docker\config.json and clear credsStore (typically
wincred or desktop), then retry an interactive docker login. See also
error getting credentials - err: exit status 1
in failure-modes.md, which is the same helper failing for dockerd-as-SYSTEM.
If that is not an option, write the auth entry directly:
$username = "<user>"
$token = "<GITHUB_PAT>"
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${username}:${token}"))
{
"auths": {
"ghcr.io": {
"auth": "<the base64 string>"
}
}
}
The value is base64, not encryption — treat that file as a credential. Prefer a short-lived PAT, and see Build secrets for getting a token into a build without it landing in a layer.
--network=host is Linux-only#
On Windows it is silently not what you want — ports must be mapped explicitly:
docker run -p 9090:9090 <image>
And from inside a container, 127.0.0.1 is the container’s loopback, not the
host’s. To reach a service running on the host, use the Docker Desktop-provided
name:
host.docker.internal
Heavy Windows container workloads#
Windows containers do not get the host’s full memory by default. For a heavy build or test run:
docker run --memory=48g <image>
DNS: “could not resolve host” inside containers#
Edit C:\ProgramData\Docker\config\daemon.json:
{
"experimental": false,
"hosts": ["npipe:////./pipe/docker_engine_windows"],
"dns": ["8.8.8.8", "8.8.4.4"]
}
Restart-Service -Name com.docker.service
Restart-Service docker
Those two service names, and the hosts line, are Docker Desktop’s. On a
Stevedore host leave the hosts line out: it is exactly the Fix 1 conflict and
stops the stevedore service from starting. Restart stevedore instead, then
re-check the CNI subnet: a dockerd start can move the nat network
(windows-host-setup.md § A5).
When the service is wedged#
On Docker Desktop (a Stevedore host restarts stevedore, as above):
Restart-Service -Name com.docker.service
Restart-Service docker
If the daemon is unreachable rather than merely stopped, the desktop app’s backend processes have to go first:
'com.docker.backend','Docker Desktop','dockerd' | ForEach-Object {
Get-Process -Name $_ -ErrorAction SilentlyContinue |
Stop-Process -Force -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 5
Start-Process -FilePath "$env:ProgramFiles\Docker\Docker\Docker Desktop.exe"
A version rollback is a legitimate fix when an update breaks the lane — the installer accepts an explicit downgrade:
.\DockerDesktopInstaller.exe install --disable-version-check
Two container-image gotchas#
MSBuild Tools are not in the base images; see Microsoft’s build-tools container guidance.
WinGet is only available on Windows Server Core 2025 images. Anything older has to install packages another way.
Delegated maintenance invariants#
Rules for the installed delegated maintenance tasks on a Windows build host. Each item is one rule.
Owner-approved v2 installation grants continuing permission to invoke its fixed preview and reclaim tasks without per-tag confirmation.
Keep its exact policy: seven completed media-branch tag families require a merged Media image and no retained container reference. Only stopped explicitly disposable containers may retire.
Preserve Final/Torch/Media, SDK/toolchain/base, unrelated tags, volumes and compiler caches.
Use the canonical selectors with full expected IDs. Never force removal, lower a disk floor, terminate a build or restart containerd.
Require real idle checks, fresh task/worker receipts, before/after preservation and measured headroom.
Inventory keeps raw containerd names and binds each distinct manifest lookup to its configuration. Native warnings refuse partial results.
Resolve hidden task instances by exact task path and GUID. Filtered instance enumeration alone never proves completion, overlap safety or revocation.
An empty nerdctl container status requires all typed inactive flags, zero PID/exit status and empty error/timestamps. Retain the raw fields and refuse native stderr.
Never execute SYSTEM code from a writable checkout or accept writable task/configuration files.
A new host needs its own administrator installation and non-admin acceptance. See the runbook.