Conversation
containers.run()/create() derive the container's volume list from the `volumes` bind strings. Only a trailing ":ro" or ":rw" was removed, so a bind such as "/src:/app:z", "/src:/app:ro,Z" or "/src:/app:cached" added "/app:z" (etc.) to Config.Volumes, and the daemon created an extra anonymous volume mounted at that literal path next to the bind. Drop whatever mode follows the destination, keeping Windows drive letters in the destination intact. Assisted-By: Claude Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com>
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.
What's wrong
containers.run()/containers.create()build the container'svolumeslist from thevolumes=[...]bind strings via_host_volume_from_bind. It only strips a trailing:roor:rw. Any other bind mode stays in the destination:Config.Volumes/src:/app:z/app:z/src:/app:ro,Z/app:ro,Z/src:/app:rw,rprivate/app:rw,rprivate/src:/app:cached/app:cachedThe daemon treats that as a separate anonymous volume. So next to the bind, every such container gets an extra anonymous volume mounted at the literal path
/app:z. The volume is left behind unless the container is removed withv=True.docker run -v /src:/app:zdoesn't do this.Reproduction against Docker Desktop (engine 27.5) on
main:The same happens with
:ro,Zand:cached. With this branch,ls /mntgives onlyx, and the only mount is the bind.Fix
After the source, drop whatever mode follows the destination. Windows drive letters in the destination are kept (
C:\src:D:\dst:ro,ZgivesD:\dst). Barero/rwhandling is unchanged.Tests
test_create_volumes_with_bind_optionsintests/unit/models_containers_test.py. It fails onmain(volumes=['/mnt/z:z', '/mnt/ro-z:ro,Z', ...]) and passes on this branch.pytest tests/unit: 615 passed, run with an isolatedHOME. Two existing tests read the developer's own~/.dockerconfig and fail the same way onmain.ruff check docker testsis clean.This was found and fixed with help from an AI coding assistant (Claude). I checked the change and reproduced the bug and the fix against a real daemon as shown above. The commit is signed off and carries an
Assisted-By:trailer.