Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[18.09] backport Fix mount propagation for btrfs #86

Merged
merged 3 commits into from
Oct 13, 2018

Conversation

kolyshkin
Copy link

Backport of moby#38026. Clean cherry-pick, no issues.

 git fetch engine
 git checkout -b 18.09-backport-btrfs-prop engine/18.09
 git cherry-pick -x f01297d1ae352bc2bf 8abadb36fa8149cd4 16d822bba8ac5ab22
 git diff engine/18.09
 git push -f kir 18.09-backport-btrfs-prop

1. There is no need to specify rw argument -- bind mounts are
   read-write by default.

2. There is no point in parsing /proc/self/mountinfo after performing
   a mount, especially if we don't check whether the fs is mounted or
   not -- the only outcome from it could be an error from our mountinfo
   parser, which makes no sense in this context.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit f01297d)
This function ensures the argument is the mount point
(i.e. if it's not, it bind mounts it to itself).

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 8abadb3)
For some reason, shared mount propagation between the host
and a container does not work for btrfs, unless container
root directory (i.e. graphdriver home) is a bind mount.

The above issue was reproduced on SLES 12sp3 + btrfs using
the following script:

	#!/bin/bash
	set -eux -o pipefail

	# DIR should not be under a subvolume
	DIR=${DIR:-/lib}
	MNT=$DIR/my-mnt
	FILE=$MNT/file

	ID=$(docker run -d --privileged -v $DIR:$DIR:rshared ubuntu sleep 24h)
	docker exec $ID mkdir -p $MNT
	docker exec $ID mount -t tmpfs tmpfs $MNT
	docker exec $ID touch $FILE
	ls -l $FILE
	umount $MNT
	docker rm -f $ID

which fails this way:

	+ ls -l /lib/my-mnt/file
	ls: cannot access '/lib/my-mnt/file': No such file or directory

meaning the mount performed inside a priviledged container is not
propagated back to the host (even if all the mounts have "shared"
propagation mode).

The remedy to the above is to make graphdriver home a bind mount.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 16d822b)
@kolyshkin kolyshkin changed the title [18.09] backport [18.09] backport Fix mount propagation for btrfs Oct 12, 2018
@andrewhsu andrewhsu added this to the 18.09.0 milestone Oct 12, 2018
Copy link

@andrewhsu andrewhsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewhsu andrewhsu merged commit 4d0b8cc into docker-archive:18.09 Oct 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants