#!/bin/bash if [ $# != 1 ];then echo "Param error";exit; fi DOCKER_NAME=$1 IMAGE_TAG=${DOCKER_NAME##*/} IMAGE=`echo $IMAGE_TAG | awk -F ':' '{print $1}'` TAG=`echo $IMAGE_TAG | awk -F ':' '{print $2}'` IMAGE_ID=`docker images | grep $IMAGE | grep $TAG | awk '{print $3}'` IMAGE_PATH=/root/images/update IP=172.18.13.6:5000 # PULL sed -i 's/172.16.161.211/172.16.161.215/g' /etc/sysconfig/docker service docker restart docker pull $1 sleep 10 # save docker save $IMAGE_ID > $IMAGE_PATH/$IMAGE.tar sleep 10 # scp scp -P 223 $IMAGE_PATH/$IMAGE.tar root@139.170.150.126:/usr/local/src/images sleep 10 # load ssh -p 223 root@139.170.150.126 "docker load < /usr/local/src/images/$IMAGE.tar" sleep 10 # tag ssh -p 223 root@139.170.150.126 "docker tag $IMAGE_ID $IP/$IMAGE:$TAG" # push ssh -p 223 root@139.170.150.126 "docker push $IP/$IMAGE:$TAG"