how to get docker image id


get running container id

shell command

containerId= `docker ps -a| grep bryce-demo | awk '{print $1}' `


if grep match multiple result , you can use this command 

containerId= `docker ps -a| grep bryce-demo | head -1|awk '{print $1}' `

head -1 mean get the head first 1 ,  tail -1 get the last 1.



containerId=`docker ps -aq --filter name=bryce-demo`
 

get image id


imageId=`docker images |grep -i $dockerHub/$namespace/$jobname:$tag | head -1 |awk '{print $3}' `



imageId=`docker images -q --filter reference=$dockerHub/$namespace/$jobname:$tag`



reference


docker docs





Comments

Popular posts from this blog

77.combinations

90.subsets-ii

40.Combination Sum II