Fix client-side race in `docker stats`
Fix client-side race in `docker stats`

Subscribe to events and monitor for new containers before the initial
listing of currently running containers.

This fixes a race where a new container could appear between the first
list call but before the client was subscribed to events, leading to a
container never appearing in the output of `docker stats`.

Signed-off-by: Arnaud Porterie <55258e89a8b41a46066b3a9514b15a78c1a88d17@docker.com>

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