Use temporary Docker client config
Change-Id: I2c864cbd553e377aa594badf4df58206e40e5794
Issue-ID: OOM-2605
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh
index 004528d..9c4b5e6 100755
--- a/build/build_nexus_blob.sh
+++ b/build/build_nexus_blob.sh
@@ -156,10 +156,8 @@
}
docker_login () {
- if ! grep -wqs ${DOCKER_REGISTRY} ~/.docker/config.json; then
- echo "Docker login to ${DOCKER_REGISTRY}"
- echo -n "${NEXUS_PASSWORD}" | docker login -u "${NEXUS_USERNAME}" --password-stdin ${DOCKER_REGISTRY} > /dev/null
- fi
+ echo "Docker login to ${DOCKER_REGISTRY}"
+ echo -n "${NEXUS_PASSWORD}" | docker --config "${DOCKER_CONFIG_DIR}" login -u "${NEXUS_USERNAME}" --password-stdin ${DOCKER_REGISTRY} > /dev/null
}
push_docker () {
@@ -181,7 +179,7 @@
PUSH="$(sed -e 's/'"${repo_host}"'/'"${DOCKER_REGISTRY}"'/' <<< ${IMAGE})"
fi
docker tag ${IMAGE} ${PUSH}
- docker push ${PUSH}
+ docker --config "${DOCKER_CONFIG_DIR}" push ${PUSH}
# Remove created tag
docker rmi ${PUSH}
echo "${IMAGE} pushed as ${PUSH} to Nexus"
@@ -279,11 +277,8 @@
NXS_DOCKER_IMG_LISTS=("${NXS_DOCKER_IMG_LIST}" "${NXS_RKE_DOCKER_IMG_LIST}" "${NXS_K8S_DOCKER_IMG_LIST}")
fi
-# Backup the current docker registry settings
-if [ -f ~/.docker/config.json ]; then
- DOCKER_CONF_BACKUP="$(eval ${TIMESTAMP}_config.json.bk)"
- mv ~/.docker/config.json ~/.docker/${DOCKER_CONF_BACKUP}
-fi
+# Create Docker client config dir
+DOCKER_CONFIG_DIR=$(mktemp -p /tmp -d .docker.XXXXXXXX)
# Setup default ports published to host as docker registry
PUBLISHED_PORTS="-p ${NEXUS_PORT}:${NEXUS_EXPOSED_PORT} -p ${NEXUS_DOCKER_PORT}:${NEXUS_DOCKER_EXPOSED_PORT}"
@@ -425,14 +420,13 @@
# Stop the Nexus and cleanup #
##############################
-echo "Stopping Nexus and returning backups"
+echo "Stopping Nexus"
# Stop the Nexus
docker stop ${NEXUS_CONT_ID} > /dev/null
-if [ -f ~/.docker/${DOCKER_CONF_BACKUP} ]; then
- mv -f ~/.docker/${DOCKER_CONF_BACKUP} ~/.docker/config.json
-fi
+# Drop temporary Docker client config dir
+rm -rf ${DOCKER_CONFIG_DIR}
echo "Nexus blob is built"
exit 0