Add error handling for registorying images (#7787)
When running the script, I faced the following error but it was difficult to know the root problem due to lack of error handling. docker tag" requires exactly 2 arguments. See 'docker tag --help'. Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE To investigate such errors easily, this adds an error handling.pull/7808/head
parent
417180246c
commit
b0fcc1ad1d
|
@ -109,6 +109,18 @@ function register_container_images() {
|
||||||
org_image=$(echo ${line} | awk '{print $2}')
|
org_image=$(echo ${line} | awk '{print $2}')
|
||||||
new_image="${LOCALHOST_NAME}:5000/${org_image}"
|
new_image="${LOCALHOST_NAME}:5000/${org_image}"
|
||||||
image_id=$(tar -tf ${IMAGE_DIR}/${file_name} | grep "\.json" | grep -v manifest.json | sed s/"\.json"//)
|
image_id=$(tar -tf ${IMAGE_DIR}/${file_name} | grep "\.json" | grep -v manifest.json | sed s/"\.json"//)
|
||||||
|
if [ -z "${file_name}" ]; then
|
||||||
|
echo "Failed to get file_name for line ${line}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${org_image}" ]; then
|
||||||
|
echo "Failed to get org_image for line ${line}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${image_id}" ]; then
|
||||||
|
echo "Failed to get image_id for file ${file_name}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
sudo docker load -i ${IMAGE_DIR}/${file_name}
|
sudo docker load -i ${IMAGE_DIR}/${file_name}
|
||||||
sudo docker tag ${image_id} ${new_image}
|
sudo docker tag ${image_id} ${new_image}
|
||||||
sudo docker push ${new_image}
|
sudo docker push ${new_image}
|
||||||
|
|
Loading…
Reference in New Issue