docker的常用命令

时间:2021-05-28 06:29:50

一些命令

docker images | grep da   docker save 3c07df65b57a > da-sc0729.tar docker load <./da-web.tar docker build -t docker.com/da/da-sc:1.0.1 . docker push docker.com/da/da-sc:1.0.1   #修改摘要值 docker tag    docker.com/da/da-sc:tomcat     $docker images | grep sc docker.com/da/da-sc            1.0.3                                                              17fe5fee092c        45 minutes ago      3.139 GB   $docker save 17fe5fee092c > sc-tomcat0228.tar   tar czvf sc-tomcat0228.tar.gz sc-tomcat0228.tar   #启动容器docker run -ti        --env-file=application-config.env   docker.com/da-sc:1.1.0

一个脚本

#!/bin/bash imageId=`docker images |grep da-sc |awk '{print $3}'` echo "imageId ${imageId[0]}" length=${#imageId[@]} if [[ $length == 0 ]];then      echo "has no image"      exit 0 fi echo "save sc images ${imageId[0]}" docker save ${imageId[0]} > sc${imageId[0]}.tar tar czvf sc${imageId[0]}.tar.gz sc${imageId[0]}.tar