! /bin/sh
接收外部引數
harbor_url=$1
harbor_project=$2
project_name=$3
tag=$4
port=$5
imageName=\(harbor_url/\)harbor_project/\(project_name:\)tag
echo "$imageName"
查詢容器是否存在,存在則刪除
containerId=docker ps -a | grep -w ${project_name}:${tag} | awk '{print $1}'
if [ "$containerId" != "" ]; then
#停止容器
docker stop $containerId
#刪除容器
docker rm $containerId
echo "成功刪除容器"
fi
查詢映象是否存在,存在則刪除
imageId=docker images | grep -w ${project_name} | awk '{print $3}'
if [ "$imageId" != "" ]; the