解决docker版本更新后获取镜像失败问题

This commit is contained in:
2025-12-31 13:48:52 +08:00
parent 9704429bf3
commit 164c13cd9f

View File

@@ -55,7 +55,7 @@ has_docker() {
# 判断是否存在当前应用的镜像 # 判断是否存在当前应用的镜像
has_image() { has_image() {
c=$(docker images|grep $IMAGE_NAME[[:blank:]]|wc -l) c=$(docker images|grep $IMAGE_NAME|wc -l)
if [ $c = 0 ] if [ $c = 0 ]
then then
return 1 return 1
@@ -65,7 +65,7 @@ has_image() {
# 判断是否存在网络连接 # 判断是否存在网络连接
checkOrCreate_network() { checkOrCreate_network() {
c=$(docker network list|grep "${NETWORK_NAME}[[:blank:]]"|wc -l) c=$(docker network list|grep "${NETWORK_NAME}"|wc -l)
if [ $c = 0 ] if [ $c = 0 ]
then then
docker network create $NETWORK_NAME >/dev/null docker network create $NETWORK_NAME >/dev/null
@@ -173,7 +173,7 @@ run() {
mkdir -p $LOG_PATH mkdir -p $LOG_PATH
fi fi
stop_jar_run stop_jar_run
latestImageId=$(docker images|grep $IMAGE_NAME[[:blank:]]|sort -r|head -1|awk '{OFS=":"}{print $1,$2}') latestImageId=$(docker images|grep $IMAGE_NAME|sort -r|head -1|awk '{OFS=":"}{print $1}')
echo "服务 $PROJECT_NAME 最新镜像ID为 $latestImageId" echo "服务 $PROJECT_NAME 最新镜像ID为 $latestImageId"
has_stop_container has_stop_container
if [ $? = 0 ] if [ $? = 0 ]
@@ -292,7 +292,7 @@ version() {
# 获取当前服务所存在的镜像版本 # 获取当前服务所存在的镜像版本
images() { images() {
has_docker has_docker
echo "当前使用镜像为:$(docker images|grep $IMAGE_NAME[[:blank:]]|awk '{OFS=":"}{print $1,$2}')" echo "当前使用镜像为:$(docker images|grep $IMAGE_NAME|awk '{OFS=":"}{print $1}')"
} }
case "$1" in case "$1" in