1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/graphdriver
Vivek Goyal e076bccb45 Make overlay home dir Private mount
People have reported following issue with overlay

$ docker run -ti --name=foo -v /dev/:/dev fedora bash
$ docker cp foo:/bin/bash /tmp
$ exit container

Upon container exit, /dev/pts gets unmounted too. This happens because
docker cp volume mounts get propagated to /run/docker/libcontainer/....
and when container exits, it must be tearing down mount point under
/run/docker/libcontainerd/... and as these are "shared" mounts it
propagates events to /dev/pts and it gets unmounted too.

One way to solve this problem is to make sure "docker cp" volume mounts
don't become visible under /run/docker/libcontainerd/..

Here are more details of what is actually happening.

Make overlay home directory (/var/lib/docker/overlay) private mount when
docker starts and unmount it when docker stops. Following is the reason
to do it.

In fedora and some other distributions / is "shared". That means when
docker creates a container and mounts it root in /var/lib/docker/overlay/...
that mount point is "shared".

Looks like after that containerd/runc bind mounts that rootfs into
/runc/docker/libcontainerd/container-id/rootfs. And this puts both source
and destination mounts points in shared group and they both are setup
to propagate mount events to each other.

Later when "docker cp" is run it sets up container volumes under
/var/lib/dokcer/overlay/container-id/... And all these mounts propagate
to /runc/docker/libcontainerd/... Now mountVolumes() makes these new
mount points private but by that time propagation already has happened
and private only takes affect when unmount happens.

So to stop this propagation of volumes by docker cp, make
/var/lib/docker/overlay a private mount point. That means when a container
rootfs is created, that mount point will be private too (it will inherit
property from parent). And that means when bind mount happens in /runc/
dir, overlay mount point will not propagate mounts to /runc/.

Other graphdrivers like devicemapper are already doing it and they don't
face this issue.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2016-04-18 21:48:09 +00:00
..
aufs Merge pull request #21714 from hallyn/2016-03-31/aufs.2 2016-04-12 14:07:51 -07:00
btrfs Merge pull request #20525 from Microsoft/sjw/update-graphdriver-create 2016-04-08 20:44:03 -07:00
devmapper parseStorageOpt: return size rather than updating devInfo.Size field 2016-04-11 10:34:13 -04:00
graphtest Merge pull request #20525 from Microsoft/sjw/update-graphdriver-create 2016-04-08 20:44:03 -07:00
overlay Make overlay home dir Private mount 2016-04-18 21:48:09 +00:00
register Move graph driver registration out of the daemon package. 2015-12-28 13:02:24 -05:00
vfs Adding readOnly parameter to graphdriver Create method 2016-04-06 13:52:53 -07:00
windows Windows: Fix Hyper-V container ACLs for TP5 (#21974) 2016-04-13 10:15:38 -07:00
zfs Adding readOnly parameter to graphdriver Create method 2016-04-06 13:52:53 -07:00
driver.go Adding readOnly parameter to graphdriver Create method 2016-04-06 13:52:53 -07:00
driver_freebsd.go Move layer mount refcounts to mountedLayer 2016-03-23 14:42:52 -07:00
driver_linux.go Move layer mount refcounts to mountedLayer 2016-03-23 14:42:52 -07:00
driver_unsupported.go daemon/graphdriver fix lint errors/warnings 2015-08-17 19:27:36 +00:00
driver_windows.go daemon/graphdriver fix lint errors/warnings 2015-08-17 19:27:36 +00:00
fsdiff.go Update daemon and docker core to use new content addressable storage 2015-11-24 09:40:25 -08:00
plugin.go Update daemon and docker core to use new content addressable storage 2015-11-24 09:40:25 -08:00
plugin_unsupported.go Create extpoint for graphdrivers 2015-09-09 20:24:35 -04:00
proxy.go Adding readOnly parameter to graphdriver Create method 2016-04-06 13:52:53 -07:00