Return non vhd volumes in container inspect - #41335
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates WSLC’s container inspect output to include Docker-managed volume mounts (guest/named/anonymous and image-defined VOLUMEs) while intentionally not exposing the utility VM’s internal source paths (emitting Source: null). It also updates schema definitions and expands tests to validate the new inspect behavior.
Changes:
- Extend Docker and WSLC inspect schemas to include mount
Nameand make WSLC mountSourcenullable. - Populate inspect
Mountswith Docker-reportedvolumemounts while continuing to map host bind mounts from WSLC’s host-side tracking. - Add/adjust Windows and E2E tests to validate anonymous and Dockerfile-defined volumes appear in inspect output with
Sourceunset.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Adds new inspect coverage for anonymous volumes and Dockerfile VOLUME mounts; updates existing mount assertions for nullable Source. |
| test/windows/wslc/e2e/WSLCE2EContainerRemoveTests.cpp | Switches anonymous-volume detection to use container inspect output rather than before/after volume list diffs. |
| src/windows/wslcsession/WSLCContainer.cpp | Updates inspect construction to append Docker volume mounts without exposing utility-VM source paths. |
| src/windows/inc/wslc_schema.h | Updates WSLC inspect mount schema to include Name and nullable Source. |
| src/windows/inc/docker_schema.h | Extends Docker inspect schema parsing to include Mounts and mount Name. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
David Bennett (dkbennett)
left a comment
There was a problem hiding this comment.
Normally I like the semantic clarity of making source optional so intent is clear, in this case it is a public schema where Source is already expected to be a string and perhaps more importantly, Docker itself uses empty string when no source applies. Nullable is cleaner conceptually but introduces a compatibility risk. If we want our json output to be consumable by tooling that expects Docker-like output, this is a change that could break that tooling.
So in the interest of Docker alignment & compat, I would recommend leaving Source as non-nullable string and leaving it empty for anonymous volumes.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/windows/wslcsession/WSLCContainer.cpp:1632
- The comment says "TODO: Return mounts once --mount is implemented", but this block already returns volume mounts today (guest volumes and Dockerfile VOLUME). This TODO is misleading; reword it to reflect the current behavior and the actual limitation (only
Type == volumemounts are surfaced; other mount types are still omitted).
// This block covers non-vhd volumes. This includes:
// - Guest volumes mounted via -v
// - Volumes mounted as part of the image (via VOLUME)
//
// TODO: Return mounts once --mount is implemented.
src/windows/inc/wslc_schema.h:36
- PR description says the volume mount Source is set to null, but the schema uses
std::string Source, so JSON serialization will emit an empty string ("Source": "") rather thannull. If consumers need an actual JSON null,Sourceshould bestd::optional<std::string>and bind mounts should explicitly populate it; otherwise, consider updating the PR description/expectations to match the empty-string behavior.
std::string Type;
std::string Name;
std::string Source;
std::string Destination;
Summary of the Pull Request
This change adds logic to return guest volumes in the container inspect's output. For now, the source path is set to an empty string since we don't want to expose VM paths, but this can be revisited later if needed
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed