1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| # deploy.sh #!/bin/bash # #
harbor_addr=$1 harbor_repo=$2 project=$3 version=$4 container_port=$5 host_port=$6
imageName=$haobor_addr/$haobor_repo/$project:$version
echo $imageName
containerId=`docker ps -a |grep ${project} | awk '{print $1}'`
echo $containerId
if [ "$containerId" != "" ]; then docker stop $containerId docker rm $containerId fi
tag=`docker images | grep ${project} | awk '{print $2}'` echo $tag
if [[ "$tag" =~ "$version" ]]; then docker rmi $imageName fi
docker login -u admin -p Harbor12345 $haobor_addr
docker pull $imageName
docker run -d -p $host_port:$container_port --name $project $imageName
echo "SUCCESS"
|