我正在提供我所面对的shell脚本的代码片段
的 Error response from daemon: service data-mapper-service not found
if [[ "$(docker service inspect ${DOCKER_SERVICE_NAME} 2> /dev/null)" != "" ]]; then
docker service rm ${DOCKER_SERVICE_NAME}
else echo "service doesn't exist or may have been removed manually"
fi
docker service create \
--name ${DOCKER_SERVICE_NAME} \
--network ${OVERLAY_NETWORK} \
--reserve-memory ${10} \
--constraint node.labels.run_images==yes \
--mode global \
--with-registry-auth \
--restart-condition any \
-p ${EXTERNAL_PORT}:${INTERNAL_PORT} \
-e "SPRING_PROFILES_ACTIVE="${SPRING_PROFILE} \
-e "JAVA_OPTS: -Xms256m -Xmx512m" \
${DTR_HOST_NAME}/${DTR_ORG_NAME}/${DTR_REP_NAME}:${BUILD_NUMBER}
我在 if statement 行上收到错误。
如果服务正在运行并且我触发了这个shell脚本,一切运行正常,但是如果服务没有运行并且我触发了这个shell脚本,我面临上面提到的错误。