1. After changing the container’s base image, the container fails to start when the Rancher environment variable CHANNEL_PUB_API_CFG_MIGRATE=true is set. Error: PHP Core Warning ‘yii\base\ErrorException’ with message ‘Module ‘gd’ already loaded’. See Figure 1.

chmod 0755 yii
chmod 0755 yii_test
... initialization completed.
CHANNEL_PUB_API_CFG_MIGRATE=true
Yii Migration Tool (based on Yii v2.0.41.1)
No new migrations found. Your system is up-to-date.
PHP Core Warning 'yii\base\ErrorException' with message 'Module 'gd' already loaded'
in ./Unknown:0
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
2. When the Rancher environment variable CHANNEL_PUB_API_CFG_MIGRATE=false is set, the container starts successfully. See Figure 2.

chmod 0755 yii
chmod 0755 yii_test
... initialization completed.
CHANNEL_PUB_API_CFG_MIGRATE=false
running without db migrate
CHANNEL_PUB_API_CFG_CONSOLE=false
copy without console
CHANNEL_PUB_API_CFG_CRONTAB_VTT=false
crontab.php not running
POD_NAMESPACE=ccp
test fail
get environment fail
ENVIRONMENT:default
POD_NAMESPACE=ccp
POD_HOSTIP=192.168.1.46
POD_IP=10.42.2.200
3. When the Rancher environment variable CHANNEL_PUB_API_CFG_MIGRATE=true is set, it essentially executes a series of command-line commands.
env | grep CHANNEL_PUB_API_CFG_MIGRATE || export CHANNEL_PUB_API_CFG_MIGRATE="false"
if [[ $CHANNEL_PUB_API_CFG_MIGRATE == "true" ]]
then
php /mcloud/www/ccp_api/yii migrate --migrationPath=@yii/log/migrations/ --interactive=0
php /mcloud/www/ccp_api/yii migrate --interactive=0
php /mcloud/www/ccp_api/yii cache/flush-schema db --interactive=0
php /mcloud/www/ccp_api/yii douyin-web-app/init-sync
php /mcloud/www/ccp_api/yii qq-tp-app/init-sync
php /mcloud/www/ccp_api/yii qq-cw-app/init-sync
php /mcloud/www/ccp_api/yii weibo-weibo-connect-web-app/init-sync
php /mcloud/www/ccp_api/yii wx-bizplugin-app/init-sync
php /mcloud/www/ccp_api/yii netease-tp-app/init-sync
elif [[ $CHANNEL_PUB_API_CFG_MIGRATE == "false" ]]
then
echo "running without db migrate"
else
echo "please set environment variable CHANNEL_PUB_API_CFG_MIGRATE true or false"
fi
4. I decided to manually execute the above commands in the successfully started container first to determine exactly which command caused the error. I set the Rancher environment variable CHANNEL_PUB_API_CFG_MIGRATE=false. I executed the first 3 commands in sequence, and all of them threw errors. See Figure 3.

[root@api-console-migrate-5788cbf65c-qkjv2 /]# php /mcloud/www/ccp_api/yii migrate --migrationPath=@yii/log/migrations/ --interactive=0
Yii Migration Tool (based on Yii v2.0.41.1)
No new migrations found. Your system is up-to-date.
PHP Core Warning 'yii\base\ErrorException' with message 'Module 'gd' already loaded'
in ./Unknown:0
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
[root@api-console-migrate-5788cbf65c-qkjv2 /]# php /mcloud/www/ccp_api/yii migrate --interactive=0
Yii Migration Tool (based on Yii v2.0.41.1)
No new migrations found. Your system is up-to-date.
PHP Core Warning 'yii\base\ErrorException' with message 'Module 'gd' already loaded'
in ./Unknown:0
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
[root@api-console-migrate-5788cbf65c-qkjv2 /]# php /mcloud/www/ccp_api/yii cache/flush-schema db --interactive=0
Schema cache for component "db", was flushed.
PHP Core Warning 'yii\base\ErrorException' with message 'Module 'gd' already loaded'
in ./Unknown:0
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
[root@api-console-migrate-5788cbf65c-qkjv2 /]#
5. I searched my tech blog for: Module ‘gd’ already loaded. I had solved a similar issue before. Reference URL: https://www.shuijingwanwq.com/2020/06/15/4240/
6. I checked if gd exists in /usr/local/php/etc/php.ini. It does. See Figure 4.

;extension = "memcached.so"
extension = "redis.so"
;extension = "mongo.so"
extension = "sockets.so"
extension = "swoole.so"
extension = "mongodb.so"
extension = "rdkafka.so"
extension = "exif.so"
extension = "imagick.so"
extension = "gd.so"
extension=mcrypt.so
7. I ultimately resolved this issue by adding the following to the Dockerfile: sed -i ‘/gd.so/d’ /usr/local/php/etc/php.ini && \.
RUN sed -i 's/open_basedir = .\/:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/tmp:\/data:\/webtv:\/usr\/local\/php/g' /usr/local/php/etc/php.ini && \
sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
sed -i 's/disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g' /usr/local/php/etc/php.ini && \
sed -i 's/;realpath_cache_ttl = 120/realpath_cache_ttl = 1200/g' /usr/local/php/etc/php.ini && \
sed -i '/gd.so/d' /usr/local/php/etc/php.ini && \
sed -i 's/memory_limit = 2048M/memory_limit = 6144M/g' /usr/local/php/etc/php.ini && \
sed -i 's/pm.max_children = 20/pm.max_children = 40/g' /usr/local/php/etc/php-fpm.conf
8. After the upgrade, I ran the relevant commands again. Error: PHP Core Warning ‘yii\base\ErrorException’ with message ‘Module ‘exif’ already loaded’. I applied the same fix by adding the following to the Dockerfile: sed -i ‘/exif.so/d’ /usr/local/php/etc/php.ini && \.
9. The next extension to throw an error in sequence was sockets. I handled it the same way. A total of 3 lines of configuration were ultimately added to the Dockerfile. See Figure 5.

10. When the Rancher environment variable CHANNEL_PUB_API_CFG_MIGRATE=true is set, the container starts successfully. See Figure 6.

chmod 0755 yii
chmod 0755 yii_test
... initialization completed.
CHANNEL_PUB_API_CFG_MIGRATE=true
Yii Migration Tool (based on Yii v2.0.41.1)
No new migrations found. Your system is up-to-date.
Yii Migration Tool (based on Yii v2.0.41.1)
Total 1 new migration to be applied:
m211104_075052_alter_ccp_tables
*** applying m211104_075052_alter_ccp_tables
> insert into {{%ccp_platform}} ... done (time: 0.025s)
> insert into {{%channel_type}} ... done (time: 0.059s)
> alter column publish_task_id in table {{%ccp_task_log}} to integer(11) NOT NULL DEFAULT 0 COMMENT '关联任务id' ... done (time: 0.116s)
> alter column account_token in table {{%ccp_platform_account}} to string(500) NOT NULL DEFAULT '' COMMENT '平台账号访问令牌' ... done (time: 0.029s)
> alter column refresh_token in table {{%ccp_platform_account}} to string(500) NOT NULL DEFAULT '' COMMENT '刷新令牌' ... done (time: 0.023s)
*** applied m211104_075052_alter_ccp_tables (time: 0.264s)
1 migration was applied.
Migrated up successfully.
Schema cache for component "db", was flushed.
抖音的网站应用模型的初始化(同步)成功
模型(企鹅号的第三方服务平台应用)创建成功
模型(企鹅号的内容网站应用)创建成功
模型(微博的微连接的网页应用)创建成功
微信的第三方平台应用模型的初始化(同步)成功
模型(网易号的第三方内容平台应用)创建成功
CHANNEL_PUB_API_CFG_CONSOLE=false
copy without console
CHANNEL_PUB_API_CFG_CRONTAB_VTT=false
crontab.php not running
POD_NAMESPACE=ccp
test fail
get environment fail
ENVIRONMENT:default
POD_NAMESPACE=ccp
POD_HOSTIP=192.168.1.48
POD_IP=10.42.3.235
