我有一个基于Alpine的docker容器,该容器运行一个使用外部数据库的AdonisJS程序。作为启动过程的一部分,我在cont-init.d目录中使用bash脚本检查数据库端点的有效性。脚本的相关部分是:
# check for the database endpoint for 30 seconds
echo " "
echo "**** Checking DB endpoint ****"
source .env
END=$((SECONDS+30))
while [ ${SECONDS} -lt ${END} ] && [ "${DB_HOST} ${DB_PORT}" ];
do
/usr/bin/nc -z ${DB_HOST} ${DB_PORT} && \
if [ ! -z "$(/usr/bin/nc -w1 ${DB_HOST} ${DB_PORT})" ];
then
[ ! -z "${RUN}" ] && break
RUN="RAN"
# we sleep here again due to first run init on DB containers
[ ! -f /dbwait.lock ] && sleep 5
else
sleep 1
fi
sleep 1
done
这似乎起作用,因为它检查以确保数据库可访问,然后继续进行。但是,我的docker日志中的输出是这样的:
**** Checking DB endpoint ****
/var/run/s6/etc/cont-init.d/50-config: line 136: warning: command substitution: ignored null byte in input
/var/run/s6/etc/cont-init.d/50-config: line 136: warning: command substitution: ignored null byte in input
我该如何解决导致此警告的原因或至少抑制该消息?