Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use rbind mount for archival and other use cases #22019

Closed
wants to merge 1 commit into from

Conversation

AkihiroSuda
Copy link
Member

- 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 than rbind.

Perhaps the content of bindtree_linux.go should be moved to daemon/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:

  • Start the daemon without systemd option MountFlags=slave.
  • On terminal 1, run docker run -it --name test_container --rm busybox, and keep the container running.
  • On terminal 2, run docker cp test_container:/bin/sh /tmp, and make sure /dev/pts is kept by running mount | grep pts.
    The original issue docker cp cause /dev/pts to be unmounted. #20670 reports that /dev/pts is unmounted at this point.
  • On terminal 1, press ^D to shut down the container, and make sure /dev/pts is still kept.
    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

Fix moby#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 moby#22009 which uses rprivate mount was not enough in a corner case described below.

How to test:

 - Start the daemon without systemd option MountFlags=slave.
 - On terminal 1, run `docker run -it --name test_container --rm busybox`, and keep the container running.
 - On terminal 2, run `docker cp test_container:/bin/sh /tmp`, and make sure /dev/pts is kept by running `mount | grep pts`.
   The original issue moby#20670 reports that /dev/pts is unmounted at this point.
 - On terminal 1, press ^D to shut down the container, and make sure /dev/pts is still kept.
   The new issue appeared in moby#22009 reports that it is unmounted at this point.

Signed-off-by: Akihiro Suda <suda.kyoto@gmail.com>
@AkihiroSuda
Copy link
Member Author

Closing this PR again, because @rhvgoyal found another way to fix the issue reported in #22009:
#22009 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants