Do not use rbind mount for archival and other use cases #22019
Closed
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 I did
Fixed #20670 and a new issue #22009 (comment)
Obsoletes #21982
Obsoletes #22009 (or maybe there is an advantage in combining #22009 to this PR for clarity)
- How I did it
Use bind mount instead of rbind.
Recursion is done in
bindtree_linux.go
rather thanrbind
.Perhaps the content of
bindtree_linux.go
should be moved todaemon/container_operations_unix.go
.I'd like to hear comments.
- How to verify it
Described in the commit message below.
Fix #20670, which reports that /dev/pts is unmounted on the host when
docker cp
is attempted to a container running with-v /dev:/dev
without the systemd option MountFlags=slave.Note that #22009 which uses rprivate mount was not enough in a corner case described below.
How to test:
docker run -it --name test_container --rm busybox
, and keep the container running.docker cp test_container:/bin/sh /tmp
, and make sure /dev/pts is kept by runningmount | grep pts
.The original issue docker cp cause /dev/pts to be unmounted. #20670 reports that /dev/pts is unmounted at this point.
The new issue appeared in Mount volumes rprivate for archival and other use cases #22009 reports that it is unmounted at this point.
Signed-off-by: Akihiro Suda suda.kyoto@gmail.com