Fix how to get image ID on offline deployment (#7808)
Previously IDs of container images were gotten from tar files of container images but that way was wrong. If multiple json files are contained in a tar file, the script got multiple IDs and tried to pass these IDs on `docker tag` command. Then the command was failed. This updates the script to get image IDs from `docker image inspect` command to fix this issue. In addition, this adds a check a registry container exists already or not before deploying registry container to avoid a container conflict failure.
This commit is contained in:
parent
627a06e30d
commit
8f44cd35d8
1 changed files with 13 additions and 5 deletions
|
@ -100,19 +100,27 @@ function register_container_images() {
|
||||||
|
|
||||||
tar -zxvf ${IMAGE_TAR_FILE}
|
tar -zxvf ${IMAGE_TAR_FILE}
|
||||||
sudo docker load -i ${IMAGE_DIR}/registry-latest.tar
|
sudo docker load -i ${IMAGE_DIR}/registry-latest.tar
|
||||||
sudo docker run --restart=always -d -p 5000:5000 --name registry registry:latest
|
|
||||||
set +e
|
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
|
set -e
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
file_name=$(echo ${line} | awk '{print $1}')
|
file_name=$(echo ${line} | awk '{print $1}')
|
||||||
org_image=$(echo ${line} | awk '{print $2}')
|
raw_image=$(echo ${line} | awk '{print $2}')
|
||||||
new_image="${LOCALHOST_NAME}:5000/${org_image}"
|
new_image="${LOCALHOST_NAME}:5000/${raw_image}"
|
||||||
image_id=$(tar -tf ${IMAGE_DIR}/${file_name} | grep "\.json" | grep -v manifest.json | sed s/"\.json"//)
|
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
|
if [ -z "${file_name}" ]; then
|
||||||
echo "Failed to get file_name for line ${line}"
|
echo "Failed to get file_name for line ${line}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [ -z "${raw_image}" ]; then
|
||||||
|
echo "Failed to get raw_image for line ${line}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if [ -z "${org_image}" ]; then
|
if [ -z "${org_image}" ]; then
|
||||||
echo "Failed to get org_image for line ${line}"
|
echo "Failed to get org_image for line ${line}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue