fix(mount): remove the non-Docker rw option from --mount#4992
Merged
Conversation
Contributor
Author
|
Verified the Docker (29.4.0) —
|
Member
The feature exists in Docker too, but the option name is different. (Out of the scope of this PR) |
AkihiroSuda
reviewed
Jun 22, 2026
4d89d96 to
d6feb20
Compare
Docker's `--mount` has no `rw` option (only `readonly`/`ro`), and in nerdctl `rw` was redundant (read-write is the default) while `rw=false` was silently ignored, leaving the mount writable. Remove `rw` from the `--mount` parser so `rw`/`rw=false` return an error, matching Docker. `ro`/`readonly`/`rro` are unchanged, and the `-v src:dst:rw` syntax is unaffected (different parser). Also fix the docs: `readonly`/`ro` are Docker-compatible, `rro` is nerdctl-specific (recursive read-only). Signed-off-by: Mayur Das <mayur.das@neevcloud.com>
d6feb20 to
7d2afb4
Compare
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.
Fixes #4991
Docker's
--mounthas norwoption — onlyreadonly/ro:In nerdctl,
--mountacceptedrw, but it was redundant (read-write is the default) andrw=falsewas silently ignored, leaving the mount writable instead of read-only.Change
rwfrom the--mountoption parser (ProcessFlagMount), sorw/rw=falsenow return an error, matching Docker.ro/readonly/rroare unchanged.-v src:dst:rwsyntax is unaffected — it's handled by a separate parser (parseVolumeOptions), and Docker supports:rwfor-v.readonly/romarked Docker-compatible (🐳);rromarked nerdctl-specific (🤓, recursive read-only).Behavioral note
--mount ...,rwnow errors instead of being a no-op. Sincerwwas the writable default (andrw=falsewas silently broken), this only affects users explicitly passing a non-standard option.Tests
TestProcessFlagMountRW:rw/rw=true/rw=falseare rejected (asserting the stable error fragments), andro/rrostill parse to their read-only options.Verified in a Linux + containerd sandbox: gofmt,
go vet, and the mountutil tests pass; manually,--mount ...,rwandrw=falseerror, while--mount ...,roand...,rrostill enforce read-only.