Upgrade the container in Rancher, the same image address, the environment variable has the container has been replaced, and the analysis solution with the container has not been replaced
1. Enter the container that the environment variable has been replaced, a configuration file, which is in line with expectations. as shown in Figure 1
2. Enter a container that has not been replaced with an environment variable, and a configuration file does not meet the expectations. as shown in Figure 2
3. View the logs of the containers whose environment variables have been replaced. There is a prompt that the corresponding environment variable has been replaced. as shown in Figure 3
2020/8/11 下午3:03:11 PCS_CFG_NGINX_SERVER_NAME=pcs.wjtest.chinamcloud.cn
2020/8/11 下午3:03:11 PCS_CFG_API_HOST_INFO=http://pcsapi.wjtest.chinamcloud.cn
2020/8/11 下午3:03:11 PCS_CFG_API_BASE_URL=/v1
2020/8/11 下午3:03:11 PCS_CFG_CALLBACK_LOGIN=http://cmcgroup.wjtest.chinamcloud.cn/login/index?call_back=http://pcs.wjtest.chinamcloud.cn/#/topic/add
2020/8/11 下午3:03:11 PCS_CFG_CMC_CONSOLE_URL=https://cmcconsole.wjtest.chinamcloud.cn
2020/8/11 下午3:03:11 PCS_CFG_CMC_CONSOLE_HEADER_LEFT_CSS=/cmc/cmc_header_left.css
2020/8/11 下午3:03:11 PCS_CFG_CMC_CONSOLE_HEADER_LEFT_JS=/cmc/cmc_header_left.js
2020/8/11 下午3:03:11 PCS_CFG_YS_FLAG=申请任务
2020/8/11 下午3:03:11 PCS_CFG_BQ_FLAG=0
2020/8/11 下午3:03:11 PCS_CFG_NGINX_SERVER_NAME replace pcs.wjtest.chinamcloud.cn -> /etc/nginx/conf.d/pcs.conf
2020/8/11 下午3:03:11 PCS_CFG_API_HOST_INFO replace http://pcsapi.wjtest.chinamcloud.cn -> /etc/nginx/conf.d/pcs.conf
2020/8/11 下午3:03:11 PCS_CFG_API_BASE_URL replace /v1 -> /etc/nginx/conf.d/pcs.conf
2020/8/11 下午3:03:11 sed: -e expression #1, char 120: unknown option to `s'
2020/8/11 下午3:03:11 PCS_CFG_CALLBACK_LOGIN replace http://cmcgroup.wjtest.chinamcloud.cn/login/index?call_back=http://pcs.wjtest.chinamcloud.cn/#/topic/add -> /mcloud/www/pcs/build/config.js
2020/8/11 下午3:03:11 PCS_CFG_CMC_CONSOLE_URL replace https://cmcconsole.wjtest.chinamcloud.cn -> /mcloud/www/pcs/build/config.js
2020/8/11 下午3:03:11 PCS_CFG_CMC_CONSOLE_HEADER_LEFT_CSS replace /cmc/cmc_header_left.css -> /mcloud/www/pcs/build/config.js
2020/8/11 下午3:03:11 PCS_CFG_CMC_CONSOLE_HEADER_LEFT_JS replace /cmc/cmc_header_left.js -> /mcloud/www/pcs/build/config.js
2020/8/11 下午3:03:11 PCS_CFG_YS_FLAG replace 申请任务 -> /mcloud/www/pcs/build/config.js
2020/8/11 下午3:03:11 PCS_CFG_BQ_FLAG replace 0 -> /mcloud/www/pcs/build/config.js
2020/8/11 下午3:03:11 /config/init/cronlog.sh: line 4: LOG_NAME: unbound variable
4. Check the logs of the containers whose environment variables are not replaced. There is no prompt that the corresponding environment variable has been replaced. And report an error: Invalid Date Invalid Date Grabbing Logs: EOF. i.e. invalid date Get log: EOF. as shown in Figure 4
Invalid Date Invalid Date grabbing logs: EOF
5. Check the container that the environment variable has not been replaced, upgrade (Upgrade) – command (command) – entry point: /bin/bash. And look at the container that the environment variable has been replaced, its value is empty. Its function is to configure the command to execute after the container is started. as shown in Figure 5
6. Edit the container that the environment variable has not been replaced, upgrade (Upgrade) – command (command) – entry point: . Set its value to be empty. Re-upgrade. The log of the container is not reported again, and the environment variable has been replaced. At this point, the command script executed after the container is started is: /config/bootstrap.sh. This script contains implementations of environment variable replacements.
#!/bin/bash
localedef -i en_US -f UTF-8 en_US.UTF-8
set -e
set -u
# Supervisord default params
SUPERVISOR_PARAMS='-c /etc/supervisord.conf'
# Create directories for supervisor's UNIX socket and logs (which might be missing
# as container might start with /data mounted from another data-container).
mkdir -p /data/conf /data/run /data/logs
chmod 711 /data/conf /data/run /data/logs
if [ "$(ls /config/init/)" ]; then
for init in /config/init/*.sh; do
. $init
done
fi
# We have TTY, so probably an interactive container...
if test -t 0; then
# Run supervisord detached...
supervisord $SUPERVISOR_PARAMS
# Some command(s) has been passed to container? Execute them and exit.
# No commands provided? Run bash.
if [[ $@ ]]; then
eval $@
else
export PS1='[\u@\h : \w]\$ '
/bin/bash
fi
# Detached mode? Run supervisord in foreground, which will stay until container is stopped.
else
# If some extra params were passed, execute them before.
# @TODO It is a bit confusing that the passed command runs *before* supervisord,
# while in interactive mode they run *after* supervisor.
# Not sure about that, but maybe when any command is passed to container,
# it should be executed *always* after supervisord? And when the command ends,
# container exits as well.
if [[ $@ ]]; then
eval $@
fi
supervisord -n $SUPERVISOR_PARAMS
fi




