Fix incorrect entrypoint for updated image
Modify update-stx-image.sh to format the original CMD and ENTRYPOINT as an array of tokens. For example ["token1", "token2"] or [""]. This way `docker commit --change` behaves as expected. Tested on: ORIG_CMD=/bin/bash ORIG_ENTRYPOINT= ORIG_CMD='/bin/bash -c' ORIG_ENTRYPOINT=/bin/bash Change-Id: If6fbe61adf15d9987dfade536a9c886ad1732580 Closes-Bug: 1906914 Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
This commit is contained in:
parent
7ad6a1a39b
commit
c72f796e17
@ -442,6 +442,28 @@ fi
|
|||||||
ORIG_CMD=$(docker inspect --format='{{.Config.Cmd}}' ${FROM} | sed -e 's/^\[//' -e 's/\]$//')
|
ORIG_CMD=$(docker inspect --format='{{.Config.Cmd}}' ${FROM} | sed -e 's/^\[//' -e 's/\]$//')
|
||||||
ORIG_ENTRYPOINT=$(docker inspect --format='{{.Config.Entrypoint}}' ${FROM} | sed -e 's/^\[//' -e 's/\]$//')
|
ORIG_ENTRYPOINT=$(docker inspect --format='{{.Config.Entrypoint}}' ${FROM} | sed -e 's/^\[//' -e 's/\]$//')
|
||||||
|
|
||||||
|
# Format the CMD and ENTRYPOINT to be valid for docker commit change
|
||||||
|
FORMATTED_ORIG_CMD=""
|
||||||
|
FORMATTED_ORIG_ENTRYPOINT=""
|
||||||
|
|
||||||
|
for token in ${ORIG_CMD}; do
|
||||||
|
FORMATTED_ORIG_CMD="${FORMATTED_ORIG_CMD}, \"${token}\""
|
||||||
|
done
|
||||||
|
if [ -z "${FORMATTED_ORIG_CMD}" ]; then
|
||||||
|
FORMATTED_ORIG_CMD="[\"\"]"
|
||||||
|
else
|
||||||
|
FORMATTED_ORIG_CMD="[${FORMATTED_ORIG_CMD:2}]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for token in ${ORIG_ENTRYPOINT}; do
|
||||||
|
FORMATTED_ORIG_ENTRYPOINT="${FORMATTED_ORIG_ENTRYPOINT}, \"${token}\""
|
||||||
|
done
|
||||||
|
if [ -z "${FORMATTED_ORIG_ENTRYPOINT}" ]; then
|
||||||
|
FORMATTED_ORIG_ENTRYPOINT="[\"\"]"
|
||||||
|
else
|
||||||
|
FORMATTED_ORIG_ENTRYPOINT="[${FORMATTED_ORIG_ENTRYPOINT:2}]"
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the OS NAME from /etc/os-release
|
# Get the OS NAME from /etc/os-release
|
||||||
OS_NAME=$(docker run --entrypoint /bin/bash --rm ${FROM} -c 'source /etc/os-release && echo ${NAME}')
|
OS_NAME=$(docker run --entrypoint /bin/bash --rm ${FROM} -c 'source /etc/os-release && echo ${NAME}')
|
||||||
|
|
||||||
@ -457,7 +479,7 @@ if [ $? -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Commit the updated image
|
# Commit the updated image
|
||||||
docker commit --change="CMD ${ORIG_CMD}" --change="ENTRYPOINT ${ORIG_ENTRYPOINT}" ${UPDATE_CONTAINER} ${UPDATED_IMAGE}
|
docker commit --change="CMD ${FORMATTED_ORIG_CMD}" --change="ENTRYPOINT ${FORMATTED_ORIG_ENTRYPOINT}" ${UPDATE_CONTAINER} ${UPDATED_IMAGE}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to commit updated image: ${UPDATE_CONTAINER}" >&2
|
echo "Failed to commit updated image: ${UPDATE_CONTAINER}" >&2
|
||||||
docker rm ${UPDATE_CONTAINER} >/dev/null
|
docker rm ${UPDATE_CONTAINER} >/dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user