Docker deployment, modify the directory sobey to mcloud, when building the image, an error is reported: Composer install returned a non-zero code: 255 analysis solution
1. Docker deployment, when building an image on Jenkins, an error is reported: composer install returned a non-zero code: 255, as shown in Figure 1
Step 7 : RUN chown -R nginx:nginx /mcloud/www/ && rm -rf /etc/nginx/conf.d/status.conf && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && cd /mcloud/www/pcs-api && composer install
---> Running in a73905f2bdbc
[91mDo not run Composer as root/super user! See https://getcomposer.org/root for details
[0mThe command '/bin/sh -c chown -R nginx:nginx /mcloud/www/ && rm -rf /etc/nginx/conf.d/status.conf && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && cd /mcloud/www/pcs-api && composer install' returned a non-zero code: 255
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE
2. The code for the failure of the dockerfile to execute the command is as follows
FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php72:0.1.12
MAINTAINER wangqiang@chinamcloud.com
RUN sed -i 's/open_basedir = .\/:\/mcloud:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/mcloud:\/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
COPY code /mcloud/www/pcs-api
COPY code/build/c_files/ /
RUN chown -R nginx:nginx /mcloud/www/ && \
rm -rf /etc/nginx/conf.d/status.conf && \
chmod +x /usr/local/bin/composer && \
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && \
cd /mcloud/www/pcs-api && \
composer install
3. Edit Dockerfile, the build is successful, the reason for the visible failure is: composer install
RUN chown -R nginx:nginx /mcloud/www/ && \
rm -rf /etc/nginx/conf.d/status.conf && \
chmod +x /usr/local/bin/composer && \
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && \
cd /mcloud/www/pcs-api
4. Edit the Dockerfile to view the list of Composer’s version information and global configuration options
RUN chown -R nginx:nginx /mcloud/www/ && \
rm -rf /etc/nginx/conf.d/status.conf && \
chmod +x /usr/local/bin/composer && \
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && \
cd /mcloud/www/pcs-api && \
composer --version && \
composer config --global --list
5. When building the image on Jenkins, it still reports an error: composer install returned a non-zero code: 255, it can be seen that the composer-related commands cannot be executed, not only composer install, as shown in Figure 2
6. Edit the Dockerfile, download the executable file of the composer, and install it locally
RUN chown -R nginx:nginx /mcloud/www/ && \
rm -rf /etc/nginx/conf.d/status.conf && \
cd /mcloud/www/pcs-api && \
curl -sS https://getcomposer.org/installer | php && \
php composer.phar install
7. When building an image on Jenkins, an error is reported: php composer.phar install returned a non-zero code: 1, as shown in Figure 3
RUN chown -R nginx:nginx /mcloud/www/ && rm -rf /etc/nginx/conf.d/status.conf && cd /mcloud/www/pcs-api && curl -sS https://getcomposer.org/installer | php && php composer.phar install
---> Running in 28a2ad979c18
All settings correct for using Composer
Warning: is_dir(): open_basedir restriction in effect. File(/root/.composer) is not within the allowed path(s): (./:/sobey:/tmp:/data:/webtv:/var/log:/mcloud) in Standard input code on line 495
Warning: is_dir(): open_basedir restriction in effect. File(/root/.composer) is not within the allowed path(s): (./:/sobey:/tmp:/data:/webtv:/var/log:/mcloud) in Standard input code on line 685
Unable to create Composer home directory "/root/.composer": mkdir(): open_basedir restriction in effect. File(/root/.composer) is not within the allowed path(s): (./:/sobey:/tmp:/data:/webtv:/var/log:/mcloud)
The command '/bin/sh -c chown -R nginx:nginx /mcloud/www/ && rm -rf /etc/nginx/conf.d/status.conf && cd /mcloud/www/pcs-api && curl -sS https://getcomposer.org/installer | php && php composer.phar install' returned a non-zero code: 1
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE
8. Awakened, the reason is that the Dockerfile file, which was replaced in batches before, replaced the sobey batch with mcloud, and decided to replace only 3 of them, and the remaining 2 places mCloud is restored to sobey, as shown in Figure 4
FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php72:0.1.12
MAINTAINER wangqiang@chinamcloud.com
RUN sed -i 's/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/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
COPY code /mcloud/www/pcs-api
COPY code/build/c_files/ /
RUN chown -R nginx:nginx /mcloud/www/ && \
rm -rf /etc/nginx/conf.d/status.conf && \
chmod +x /usr/local/bin/composer && \
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && \
cd /mcloud/www/pcs-api && \
composer install
9. Docker deployment, the image is successfully built on Jenkins, and the subsequent replacement can only be performed after the basic image upgrade. as shown in Figure 5




