Make overlay home dir Private mount
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 <61d11262d0d9873ddb5a887f48fcb04e8c5973d0@redhat.com>

mixja/docker,madhanrm/docker,rhatdan/storage,rhatdan/docker,sean-jc/docker,hqhq/moby,tklauser/docker,JimGalasyn/docker.github.io,pradipd/moby,denverdino/denverdino.github.io,LuisBosquez/docker.github.io,cpuguy83/docker,endophage/docker,gjaskiewicz/moby,tmp6154/docker,akira-baruah/docker,shhsu/docker,dgageot/docker,cloudflare/docker,joaofnfernandes/docker.github.io,gdevillele/docker.github.io,asbjornenge/docker,danix800/docker.github.io,YuPengZTE/docker,erikstmartin/docker,endophage/docker,laijs/moby,TheBigBear/docker,shhsu/docker,msabansal/docker,justyntemme/docker,bfirsh/docker,SvenDowideit/docker,mtanlee/docker,mike1729/docker,nalind/docker,mstanleyjones/docker,erikstmartin/docker,rhardih/docker,ajaymdesai/docker,thaJeztah/docker.github.io,thaJeztah/docker,kencochrane/docker,jlebon/docker,paralin/docker,Shopify/docker,jongiddy/docker,splunk/docker,xiaods/docker,dongjoon-hyun/docker,scotttlin/docker,HuKeping/docker,tklauser/docker,justyntemme/docker,pecameron/docker,sfsmithcha/docker,tianon/docker,errordeveloper/docker,PatrickLang/moby,Tenk42/docker,docker/docker.github.io,dccurtis/docker,docker/docker.github.io,mikedougherty/docker,mstanleyjones/docker,JMesser81/docker,sdurrheimer/docker,ibuildthecloud/docker,sunyuan3/docker,sdurrheimer/docker,gschaetz/moby,maxamillion/docker,wenchma/docker,asbjornenge/docker,mtanlee/docker,yongtang/docker,KarthikNayak/docker,srust/docker,justincormack/docker,xuxinkun/docker,jvanz/docker,jlebon/docker,dgageot/docker,dsheets/moby,allencloud/docker,cyphar/docker,gdevillele/docker.github.io,tkopczynski/docker,yosifkit/docker,tophj-ibm/moby,BenHall/docker,toli/docker,willmtemple/docker,moypray/docker,trebonian/docker,moby/moby,noxiouz/docker,shishir-a412ed/docker,eskaaren/docker,toli/docker,denverdino/docker.github.io,michelvocks/docker,phiroict/docker,Mashimiao/docker,catinthesky/docker,michael-holzheu/docker,konstruktoid/docker-1,bearstech/moby,raja-sami-10p/moby,Syntaxide/docker,jimjag/docker,AkihiroSuda/docker,bearstech/moby,resin-io/docker,londoncalling/docker.github.io,noironetworks/docker,thaJeztah/docker,AkihiroSuda/docker,sheimi/docker,konstruktoid/docker-upstream,splunk/docker,rhatdan/docker,liaoqingwei/docker,kerneltime/docker,thaJeztah/docker,shin-/docker.github.io,rancher/docker,raja-sami-10p/moby,vdemeester/docker,djs55/docker,vdemeester/docker,yummypeng/docker,sarnautov/moby,brahmaroutu/docker,moul/docker,tophj-ibm/moby,lixiaobing1/docker,flavio/docker,kojiromike/docker,coreos/docker,isubuz/docker,endophage/docker,KarthikNayak/docker,whuwxl/docker,alexisbellido/docker.github.io,Altiscale/docker,dims/docker,yasiramin10p/moby,moul/docker,abhinavdahiya/docker,xuxinkun/docker,stevvooe/docker,Shopify/docker,medallia/docker,erikstmartin/docker,kunalkushwaha/docker,johnstep/moby-moby,michelvocks/docker,tagomoris/docker,docker/docker,miminar/docker,jwhonce/docker,HideoYamauchi/docker,zhuguihua/docker,mahak/docker,sanscontext/docker.github.io,cr7pt0gr4ph7/docker,willmtemple/docker,splunk/docker,menglingwei/denverdino.github.io,moypray/docker,dnephin/docker,pecameron/docker,estesp/docker,aduermael/docker.github.io,BenHall/docker,unclejack/docker,moul/docker,HideoYamauchi/docker,moul/docker,jwhonce/docker,duglin/docker,portworx/docker,bdwill/docker.github.io,jameszhan/docker,flavio/docker,rillig/docker.github.io,troy0820/docker.github.io,pradipd/moby,tklauser/docker,isubuz/docker,Mokolea/docker,erikh/docker,Syntaxide/docker,mstanleyjones/docker,moby/moby,denverdino/denverdino.github.io,TheBigBear/docker,menglingwei/denverdino.github.io,naveed-jamil-tenpearls/moby,sheimi/docker,yummypeng/docker,flavio/docker,yosifkit/docker,danix800/docker.github.io,crosbymichael/docker,jvanz/docker,charleswhchan/docker,ndeloof/docker,noironetworks/docker,tonistiigi/docker,mtrmac/docker,charleswhchan/docker,Tenk42/docker,mikedougherty/docker,sdurrheimer/docker,miminar/docker,icaoweiwei/docker,charleszheng44/moby,xiaods/docker,rancher/docker,michael-holzheu/docker,nawawi/docker,qudongfang/docker,rillig/docker.github.io,mohmost12/docker,pramodhkp/moby,unclejack/docker,moxiegirl/docker,lixiaobing1/docker,nawawi/docker,jlhawn/docker,thaJeztah/docker.github.io,menglingwei/denverdino.github.io,mtrmac/docker,sarnautov/moby,moby/moby,sfsmithcha/docker,LuisBosquez/docker.github.io,ndeloof/docker,djs55/docker,jlhawn/docker,thaJeztah/docker,coolljt0725/docker,JimGalasyn/docker.github.io,Shopify/docker,laijs/docker,mkumatag/docker,wenchma/docker,medallia/docker,resin-io/docker,srust/docker,Altiscale/docker,msabansal/docker,tianon/docker,jzwlqx/denverdino.github.io,tmp6154/docker,hqhq/moby,pramodhkp/moby,trebonian/docker,bfirsh/docker,BSWANG/denverdino.github.io,sfsmithcha/docker,mkumatag/docker,BSWANG/denverdino.github.io,bearstech/moby,rremer/moby,13W/docker,HideoYamauchi/docker,jvanz/docker,alfred-landrum/docker,duglin/docker,afein/docker,mikedougherty/docker,tagomoris/docker,ffoysal/docker,laijs/docker,coreos/docker,cr7pt0gr4ph7/docker,thtanaka/docker,eskaaren/docker,yasiramin10p/moby,ffoysal/docker,errordeveloper/docker,KingEmet/docker,eskaaren/docker,DoraALin/docker,docker/docker,anweiss/docker.github.io,Ramzec/docker,prertik/docker,estesp/docker,qudongfang/docker,nalind/docker,BSWANG/denverdino.github.io,sterchelen/docker,sterchelen/docker,Morsicus/docker,mike1729/docker,gnailuy/docker,yasiramin10p/moby,SvenDowideit/docker,charleswhchan/docker,troy0820/docker.github.io,gnailuy/docker,xiekeyang/docker,trebonian/docker,twaugh/docker,tkopczynski/docker,gnailuy/docker,gjaskiewicz/moby,dgageot/docker,aduermael/docker.github.io,Mokolea/docker,abhinavdahiya/docker,bfirsh/docker,tkopczynski/docker,sunyuan3/docker,gschaetz/moby,coolljt0725/docker,errordeveloper/docker,estesp/docker,14rcole/docker,mgoelzer/docker,icaoweiwei/docker,lixiaobing10051267/docker,djs55/docker,shhsu/docker,pradipd/moby,Morsicus/docker,flavio/docker,phiroict/docker,mikebrow/docker,amatsus/docker,mahak/docker,kolyshkin/docker,ibuildthecloud/docker,gdevillele/docker.github.io,anweiss/docker.github.io,shin-/docker.github.io,nalind/docker,alexisbellido/docker.github.io,johnstep/moby-moby,yummypeng/docker,HuKeping/docker,Ramzec/docker,14rcole/docker,shin-/docker.github.io,gnailuy/docker,rhatdan/storage,paralin/docker,imkin/moby,londoncalling/docker.github.io,shin-/docker.github.io,moxiegirl/docker,prertik/docker,ripcurld0/moby,thaJeztah/docker.github.io,YuPengZTE/docker,13W/docker,srust/docker,LaynePeng/docker,aduermael/docker.github.io,justincormack/docker,mtesselH/docker,BenHall/docker,cpuguy83/docker,docker/docker.github.io,alexisbellido/docker.github.io,Mashimiao/docker,sanjeo/docker,bdwill/docker.github.io,yp-engineering/docker,HuKeping/docker,PatrickLang/moby,x1022as/docker,kerneltime/docker,zhuguihua/docker,anujbahuguna/docker,dmcgowan/docker,Altiscale/docker,DoraALin/docker,imkin/moby,mikebrow/docker,nghiant2710/docker,paralin/docker,projectatomic/docker,jongiddy/docker,bearstech/moby,konstruktoid/docker-upstream,ajaymdesai/docker,jhorwit2/docker,kunalkushwaha/docker,jwhonce/docker,JMesser81/docker,whuwxl/docker,nghiant2710/docker,denverdino/docker.github.io,tonistiigi/docker,johnstep/docker.github.io,darrenstahlmsft/moby,londoncalling/docker.github.io,johnstep/docker.github.io,joeuo/docker.github.io,crosbymichael/docker,catinthesky/docker,rillig/docker.github.io,danix800/docker.github.io,wenchma/docker,cyphar/docker,docker-zh/docker.github.io,alexisbellido/docker.github.io,brahmaroutu/docker,JimGalasyn/docker.github.io,bluebreezecf/docker,jimjag/docker,troy0820/docker.github.io,konstruktoid/docker-1,mixja/docker,ripcurld0/moby,thtanaka/docker,jthelin/docker,dnephin/docker,anweiss/docker.github.io,darrenstahlmsft/docker,joaofnfernandes/docker.github.io,jzwlqx/denverdino.github.io,stevvooe/docker,konstruktoid/docker-1,containers/storage,mahak/docker,gigidwan/docker,gdevillele/docker.github.io,JimGalasyn/docker.github.io,shubheksha/docker.github.io,thaJeztah/docker.github.io,kolyshkin/moby,erikh/docker,zhuguihua/docker,rancher/docker,xiekeyang/docker,nawawi/docker,Ramzec/docker,Syntaxide/docker,tagomoris/docker,noxiouz/docker,amatsus/docker,gschaetz/moby,TheBigBear/docker,bonczj/moby-json-file-logger,raja-sami-10p/moby,duglin/docker,LaynePeng/docker,mtrmac/docker,rhatdan/storage,pramodhkp/moby,allencloud/docker,maxamillion/docker,laijs/docker,mahak/docker,joeuo/docker.github.io,sunyuan3/docker,twaugh/docker,cloudflare/docker,JMesser81/docker,KarthikNayak/docker,cr7pt0gr4ph7/docker,toli/docker,docker-zh/docker.github.io,jimjag/docker,Mokolea/docker,michelvocks/docker,dsau/docker,haveatry/docker,bonczj/moby-json-file-logger,haveatry/docker,LuisBosquez/docker.github.io,ColinHebert/docker,anujbahuguna/docker,sanscontext/docker.github.io,lixiaobing1/docker,dongjoon-hyun/docker,denverdino/docker.github.io,stevvooe/docker,portworx/docker,harche/docker,moypray/docker,stainboy/docker,anujbahuguna/docker,containers/storage,ibuildthecloud/docker,allencloud/docker,cloudflare/docker,phiroict/docker,gdevillele/docker.github.io,Mashimiao/docker,q384566678/docker,charleszheng44/moby,troy0820/docker.github.io,docker-zh/docker.github.io,liaoqingwei/docker,madhanrm/docker,jhorwit2/docker,bonczj/moby-json-file-logger,paralin/docker,danyalKhaliq10p/moby,xiekeyang/docker,rhardih/docker,kojiromike/docker,gigidwan/docker,ColinHebert/docker,dmcgowan/docker,shubheksha/docker.github.io,denverdino/docker.github.io,londoncalling/docker.github.io,tophj-ibm/moby,fcrisciani/docker,icaoweiwei/docker,kerneltime/docker,13W/docker,denverdino/denverdino.github.io,bdwill/docker.github.io,cpuguy83/docker,londoncalling/docker.github.io,konstruktoid/docker-upstream,stainboy/docker,jzwlqx/denverdino.github.io,dnephin/docker,POLJM242/docker,yp-engineering/docker,AkihiroSuda/docker,mtesselH/docker,dsau/docker,gjaskiewicz/moby,konstruktoid/docker-upstream,AkihiroSuda/docker,diogomonica/docker,x1022as/docker,kencochrane/docker,bluebreezecf/docker,phiroict/docker,isubuz/docker,kolyshkin/moby,mgoelzer/docker,cpuguy83/docker,miminar/docker,hypriot/docker,akira-baruah/docker,johnstep/docker.github.io,alfred-landrum/docker,haveatry/docker,shishir-a412ed/docker,denverdino/denverdino.github.io,harche/docker,nalind/docker,13W/docker,joaofnfernandes/docker.github.io,13W/docker,menglingwei/denverdino.github.io,trebonian/docker,joaofnfernandes/docker.github.io,projectatomic/docker,mohmost12/docker,pecameron/docker,KingEmet/docker,tmp6154/docker,erikh/docker,darrenstahlmsft/moby,coreos/docker,sanjeo/docker,mkumatag/docker,crosbymichael/docker,ripcurld0/moby,dccurtis/docker,moxiegirl/docker,whuwxl/docker,q384566678/docker,johnstep/docker.github.io,joaofnfernandes/docker.github.io,willmtemple/docker,sheimi/docker,xiaods/docker,anweiss/docker.github.io,ibuildthecloud/docker,afein/docker,unclejack/docker,sanscontext/docker.github.io,thaJeztah/docker.github.io,denverdino/denverdino.github.io,jthelin/docker,yosifkit/docker,scotttlin/docker,laijs/moby,docker-zh/docker.github.io,shubheksha/docker.github.io,qudongfang/docker,dsau/docker,scotttlin/docker,laijs/moby,ndeloof/docker,brahmaroutu/docker,tophj-ibm/docker,darrenstahlmsft/moby,LuisBosquez/docker.github.io,prertik/docker,afein/docker,thtanaka/docker,rillig/docker.github.io,ffoysal/docker,POLJM242/docker,yongtang/docker,jameszhan/docker,docker/docker.github.io,mohmost12/docker,fcrisciani/docker,docker/docker.github.io,liaoqingwei/docker,KingEmet/docker,SvenDowideit/docker,tophj-ibm/docker,bdwill/docker.github.io,lixiaobing10051267/docker,JimGalasyn/docker.github.io,kencochrane/docker,joeuo/docker.github.io,sanscontext/docker.github.io,rremer/moby,darrenstahlmsft/docker,denverdino/docker.github.io,containers/storage,harche/docker,joeuo/docker.github.io,yp-engineering/docker,joeuo/docker.github.io,johnstep/moby-moby,rhatdan/docker,LuisBosquez/docker.github.io,kolyshkin/moby,hqhq/moby,mikebrow/docker,danyalKhaliq10p/moby,sarnautov/moby,hypriot/docker,noironetworks/docker,dsheets/moby,msabansal/docker,ajaymdesai/docker,rremer/moby,tophj-ibm/docker,anweiss/docker.github.io,shubheksha/docker.github.io,projectatomic/docker,diogomonica/docker,BSWANG/denverdino.github.io,abhinavdahiya/docker,jameszhan/docker,coolljt0725/docker,DoraALin/docker,mtesselH/docker,bdwill/docker.github.io,mike1729/docker,jzwlqx/denverdino.github.io,Ramzec/docker,x1022as/docker,michael-holzheu/docker,alfred-landrum/docker,hypriot/docker,asbjornenge/docker,justyntemme/docker,dperny/docker,madhanrm/docker,jlebon/docker,dongjoon-hyun/docker,jzwlqx/denverdino.github.io,docker/docker,dsheets/moby,jlhawn/docker,jongiddy/docker,sanscontext/docker.github.io,shishir-a412ed/docker,sean-jc/docker,q384566678/docker,naveed-jamil-tenpearls/moby,medallia/docker,mtanlee/docker,ibuildthecloud/docker,BSWANG/denverdino.github.io,justincormack/docker,maxamillion/docker,shin-/docker.github.io,Mokolea/docker,naveed-jamil-tenpearls/moby,dmcgowan/docker,danyalKhaliq10p/moby,danix800/docker.github.io,dccurtis/docker,cyphar/docker,PatrickLang/moby,diogomonica/docker,jhorwit2/docker,xuxinkun/docker,dperny/docker,catinthesky/docker,LaynePeng/docker,Morsicus/docker,sterchelen/docker,mgoelzer/docker,lixiaobing10051267/docker,docker-zh/docker.github.io,fcrisciani/docker,phiroict/docker,charleszheng44/moby,yongtang/docker,darrenstahlmsft/docker,Tenk42/docker,yosifkit/docker,mixja/docker,tonistiigi/docker,kunalkushwaha/docker,noxiouz/docker,dims/docker,shubheksha/docker.github.io,sanjeo/docker,stainboy/docker,ColinHebert/docker,gigidwan/docker,bluebreezecf/docker,twaugh/docker,amatsus/docker,kojiromike/docker,moby/moby,alexisbellido/docker.github.io,resin-io/docker,dperny/docker,johnstep/docker.github.io,jimjag/docker,sean-jc/docker,nghiant2710/docker,kolyshkin/docker,dims/docker,vdemeester/docker,menglingwei/denverdino.github.io,nawawi/docker,YuPengZTE/docker,medallia/docker,portworx/docker,aduermael/docker.github.io,imkin/moby