Skip to content

Document WSLC session and elevation model - #158

Merged
japperJ merged 1 commit into
masterfrom
japperj-wsl2-admin-elevation-review
Sep 10, 2026
Merged

japperJ merged 1 commit into
masterfrom
japperj-wsl2-admin-elevation-review

Conversation

@japperJ

@japperJ japperJ commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Why

Wincontainer's elevation requirement was undocumented, and the reason is not obvious from the code. WSLC selects the container session from the elevation level of the calling process, so elevated and non-elevated callers land in separate VHD-backed stores under %LOCALAPPDATA%\wslc\sessions\ that cannot see each other. wslc container list has no --session flag to bridge them. That mismatch is the root cause of the recurring "the site works locally but Wincontainer is empty" problem, and of a hard failure where a non-elevated wslc call errors with E_INVALIDARG instead of returning an empty list.

What changed

  • Added a Sessions and elevation section to README.md: the elevation-to-session mapping table, why the two stores are isolated, and the two distinct reasons admin is needed (session identity vs. privileged setup for wsl --install and the WSLC MSI).
  • Documented that the non-elevated session is WSLC's default, not a Wincontainer concept: WSLC is designed to run containers without administrator rights, so any non-elevated caller gets its own session on demand. Wincontainer lands in the admin session only because the app runs elevated.
  • Noted the non-elevated session's practical use as scratch space, which the deploy skill already relies on: build there so bind mounts and the 15-volume limit stay out of the admin session.
  • Added the Docker Desktop contrast: it never elevates its UI because privileged work lives in a LocalSystem service and the engine runs unprivileged inside the WSL2 distro. Wincontainer runs its service in-process, so the app process carries the elevation today.
  • Extended .github/skills/deploying-to-wincontainer/SKILL.md with the same model plus a Diagnosing session problems block (Get-ChildItem on the sessions dir, system session list --verbose, the E_INVALIDARG error text and its fix), and added that error to the Common mistakes table.

Notes

  • Documentation only. No code, no behavior change.
  • The E_INVALIDARG failure mode is live on the dev machine: wslc-cli-jptrs holds a swap.vhdx with no storage.vhdx, so every non-elevated wslc call fails. Not fixed here; removing the stale directory is a manual step and is documented rather than automated.
  • The underlying design question is untouched: splitting the privileged control plane into a service so the UI can stay asInvoker would remove the daily UAC cost. This PR only makes the current model legible.

Testing

  • N/A. Markdown-only change; no build or test surface affected.
  • Verified the session directories, wslc system session list, and the E_INVALIDARG reproduction directly against wslc 2.9.4.0 on the dev machine.

WSLC picks the container session from the elevation level of the calling
process, so elevated and non-elevated callers get separate VHD-backed
stores that cannot see each other. This was undocumented and is the root
cause of "the site works locally but Wincontainer is empty".

Explain the elevation-to-session mapping, why the non-elevated session is
WSLC's default rather than a Wincontainer concept, how this differs from
Docker Desktop's LocalSystem service, and how to diagnose a stale session
directory that makes wslc fail with E_INVALIDARG.
@japperJ
japperJ merged commit 566d73b into master Sep 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant