Preserve readonly flag when converting mounts to -v for WSLc - #1314
Open
Akio Takahashi (akiotakahashi) wants to merge 2 commits into
Open
Akio Takahashi (akiotakahashi) wants to merge 2 commits into
Akio Takahashi (akiotakahashi) wants to merge 2 commits into
Conversation
Akio Takahashi (akiotakahashi)
requested a review
from a team
as a code owner
September 30, 2026 16:31
Author
|
@microsoft-github-policy-service agree |
The WSLc code path converts --mount strings to -v syntax but dropped the readonly/ro option, so every mount declared readonly in devcontainer.json was mounted writable. wslc supports the "-v source:target:ro" suffix (verified with wslc 3.0.1), so append ":ro" when the mount string carries readonly/ro unless its value is explicitly false. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018psPhUnN32LKjqd4ZkATtP
Keep consistency=cached in the example so it still illustrates that options other than source/target/readonly are dropped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018psPhUnN32LKjqd4ZkATtP
Akio Takahashi (akiotakahashi)
force-pushed
the
fix-wslc-readonly-mounts
branch
from
October 2, 2026 14:55
1a16840 to
b6ca47c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the CLI drives WSL containers (
--docker-path wslc,CLIVariant.Wslcadded in #1249),--mountstrings are converted to-vsyntax byconvertMountToVolumeinsrc/spec-node/singleContainer.ts. The conversion only readssourceandtarget, so thereadonly/rooption is silently dropped for theworkspaceMountand for every entry ofmounts. Mounts that a devcontainer.json declares readonly end up writable inside the container.Observed with @devcontainers/cli 0.89.0 and wslc 3.0.1 (GA) on Windows 11: a config with 15
readonlymounts produced awslc runcommand line containing no:roat all, and a file behind a readonly mount could be modified from inside the container.wslc itself supports the readonly suffix —
wslc run -v C:/path:/mnt:ro ...correctly yields a read-only mount (verified with wslc 3.0.1, including drive-letter source paths) — so this is purely a conversion issue.Fix
convertMountToVolumenow appends:rowhen the mount string carriesreadonlyorro(bare, or with a value other thanfalse/0), matching Docker's--mountsemantics. Other options (type,consistency) are dropped as before.The function is exported for testing and unit tests are added in
src/test/singleContainer.test.tscovering the bare/valuedreadonly/roforms,readonly=false, named volumes, Windows source paths, and the target-only and fallback paths.Notes
generateMountCommandnever emitsreadonlyfor them, and theMountinterface has no such field.🤖 Generated with Claude Code
https://claude.ai/code/session_018psPhUnN32LKjqd4ZkATtP