diff --git a/contrib/offline/manage-offline-container-images.sh b/contrib/offline/manage-offline-container-images.sh index b64d7b748..891441c5f 100755 --- a/contrib/offline/manage-offline-container-images.sh +++ b/contrib/offline/manage-offline-container-images.sh @@ -100,19 +100,27 @@ function register_container_images() { tar -zxvf ${IMAGE_TAR_FILE} sudo docker load -i ${IMAGE_DIR}/registry-latest.tar - sudo docker run --restart=always -d -p 5000:5000 --name registry registry:latest set +e - + sudo docker container inspect registry >/dev/null 2>&1 + if [ $? -ne 0 ]; then + sudo docker run --restart=always -d -p 5000:5000 --name registry registry:latest + fi set -e + while read -r line; do file_name=$(echo ${line} | awk '{print $1}') - org_image=$(echo ${line} | awk '{print $2}') - new_image="${LOCALHOST_NAME}:5000/${org_image}" - image_id=$(tar -tf ${IMAGE_DIR}/${file_name} | grep "\.json" | grep -v manifest.json | sed s/"\.json"//) + raw_image=$(echo ${line} | awk '{print $2}') + new_image="${LOCALHOST_NAME}:5000/${raw_image}" + org_image=$(sudo docker load -i ${IMAGE_DIR}/${file_name} | head -n1 | awk '{print $3}') + image_id=$(sudo docker image inspect ${org_image} | grep "\"Id\":" | awk -F: '{print $3}'| sed s/'\",'//) if [ -z "${file_name}" ]; then echo "Failed to get file_name for line ${line}" exit 1 fi + if [ -z "${raw_image}" ]; then + echo "Failed to get raw_image for line ${line}" + exit 1 + fi if [ -z "${org_image}" ]; then echo "Failed to get org_image for line ${line}" exit 1