wslc: containers do not inherit image labels (Config.Labels missing), silently breaking VS Code Dev Containers Feature lifecycle hooks
Windows Version
Microsoft Windows [Version 10.0.26200.8893]
WSL Version
2.9.4.0
Are you using WSL 1 or WSL 2?
- [X] WSL 2
- [ ] WSL 1
Kernel Version
6.18.35.2-1
Distro Version
Ubuntu 24.04
Other Software
- wslc 2.9.4.0 (
wslc version) - VS Code 1.130.0, Dev Containers extension 0.467.0 (affected downstream)
@devcontainers/cli0.88.0- For comparison: Docker Engine (any recent version) exhibits the expected behavior
Repro Steps
The repro is independent of VS Code / Dev Containers — three commands from a WSL distro (or the Windows side, with wslc.exe):
printf 'FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04\nLABEL test.label="hello-from-image"\n' > Dockerfile
wslc build -t label-test .
wslc run -d --name label-test-c label-test sleep infinity
# Image inspect: label is present
wslc inspect --type image label-test # -> Config.Labels contains "test.label": "hello-from-image"
# Container inspect: label is gone
wslc inspect label-test-c # -> Config.Labels is absent entirely
Cleanup: wslc rm -f label-test-c; wslc rmi label-test
Expected Behavior
Containers created from an image inherit the image's labels, as with Docker Engine. docker inspect <container> shows Config.Labels populated with the image's labels merged with any --label flags (user-provided labels win on conflict).
References:
- Dockerfile reference (
LABEL): "Labels included in base images (images in theFROMline) are inherited by your image." — https://docs.docker.com/reference/dockerfile/#label - Docker Engine implementation: at container create, the daemon merges the image config into the container config, including labels —
mergeAndVerifyConfigindaemon/create.gocallingmerge()(daemon/commit.go, theimageConf.Labelsloop).
Expected wslc inspect label-test-c (excerpt):
"Config": {
"Labels": {
"test.label": "hello-from-image",
"...": "(labels inherited from the base image)"
}
}
Actual Behavior
wslc inspect <container> returns a Config object with no Labels key at all (observed keys: Cmd, Entrypoint, Env, Healthcheck, StopTimeout, User, WorkingDir). The top-level Labels field contains only labels passed explicitly via --label at run/create time. Image labels are never propagated to the container.
wslc inspect --type image does show the labels correctly, so the metadata survives wslc build; it is only the image-to-container inheritance step that is missing.
Real-world impact: VS Code Dev Containers silently loses Feature lifecycle hooks
The Dev Containers spec stores merged Feature metadata (including onCreateCommand / postCreateCommand contributed by Features) as a devcontainer.metadata image label, which tooling later reads back from the container:
- containers.dev spec: "The metadata is added to the image as a
devcontainer.metadatalabel with a JSON string value" and it is "merged with any local devcontainer.json file contents at the time the container is created" — https://containers.dev/implementors/spec/#image-metadata @devcontainers/clireads it viacontainerDetails.Config.Labels['devcontainer.metadata']and falls back to empty metadata when the label is absent —src/spec-node/imageMetadata.ts,getImageMetadataFromContainer
The VS Code Dev Containers extension runs devcontainer up --skip-post-create and then executes lifecycle hooks in a separate run-user-commands phase that resolves hooks from the container's devcontainer.metadata label. With wslc, the label is invisible on the container, so all Feature-contributed lifecycle commands are silently skipped — no error, the container just comes up missing everything a Feature's onCreateCommand was supposed to install. I hit this in practice with a Nix devcontainer Feature: the container started, but nix/direnv were absent because onCreateCommand never ran; the marker files were written but no command executed.
This makes any devcontainer Feature that relies on lifecycle hooks (most non-trivial ones) unusable with wslc when opened through VS Code, in a way that is very hard for users to diagnose.
Note that wslc support was deliberately added to the Dev Containers tooling recently (@devcontainers/cli 0.88.0, devcontainers/cli#1249; Dev Containers extension 0.462.0+). That work adapts to several wslc differences (e.g. no events command → polling fallback, --mount → volume-arg conversion), but the Features metadata path still assumes Docker's image-label inheritance, so this incompatibility remains unhandled on the tooling side. I found no statement in the VS Code Dev Containers documentation, the WSL container documentation (wsl-container, containers tutorial), or either project's changelog declaring label inheritance (or Feature lifecycle hooks) as a known limitation.
Prior-issue search: I reviewed the wslc-related issues in this repo (~50, e.g. #14432 volume-flag differences, #40957 bind mounts, #41123 image store) and in microsoft/vscode-remote-release (#11694 tracking, #11750, #11725, #11723) and devcontainers/cli — no existing report of missing image-label inheritance.
Diagnostic Logs
No response
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
Diagnostic information
.wslconfig found
Detected appx version: 2.9.4.0
The impact on VS Code Dev Containers is worth calling out explicitly because it's a silent failure: the Dev Containers extension uses image labels to discover Feature lifecycle hooks (e.g. devcontainer.metadata), and if Config.Labels is missing from the image inspect output, those hooks never fire. The container starts and looks fine — but features like ghcr.io/devcontainers/features/docker-in-docker silently skip their post-create steps.
The VS Code team documents that Dev Containers works with wslc when you set dev.containers.dockerPath to wslc (https://code.visualstudio.com/docs/devcontainers/containers#_docker-path), and basic scenarios do work — but this Labels gap means Feature lifecycle hooks are silently broken on the wslc backend. The Docker-API compatibility gap (#40976) and the bind-mount gap (#40957) are the other two blockers for full Dev Containers support on wslc.
(I have a write-up tracking which Dev Containers scenarios work on wslc 2.9.4.0 at https://wslcontainers.com/guides/vscode-dev-containers/ — this Labels gap is the newest addition to the known-issues list.)