Fix flaky test of TestRestartStoppedContainer (#21211).
Fix flaky test of TestRestartStoppedContainer (#21211).

This fix addressed the issue of test TestRestartStoppedContainer
in #21211. Inside the test, a `docker restart` command is
followed by a `docker logs` command. However, `docker restart`
returns immediately so there is no guarantee that `docker logs`
will wait until the restarted container completes the command
`echo foobar`.

This fix use the check of `{{.State.Running}} = false` to make
sure that the restarted container has already finished, before
invoking the `docker logs` command. The timeout is set to 20s
to make sure it passes WindowsTP4 check.

This fixes #21211.

Signed-off-by: Yong Tang <765086fe2e0c1f980161f127fec596800f327f62@outlook.com>

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