I encountered a similar problem, which can be fixed in the following ways:
- Method 1: based on
docker cp
, copy the file contents of the damaged container to the current environment (even if the container cannot be started);
- Method 2: based on
docker commit
resubmit the damaged container as another image, and then start the additional entry point entry;
Note: the above methods are just a few tricks to use during debugging or development, and eventually we should write the related operations into the Dockerfile
configuration or docker-compose.yml
configuration.
Fix Progress:
- Because I temporarily modified the
./php-fpm.d/www.conf
configuration in my PHP-FPM
container, the container could not be started:
$ docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------
phpfpm_fpm_1 docker-php-entrypoint php-fpm Restarting
phpfpm_nginx_1 nginx -g daemon off; Up 80/tcp, 0.0.0.0:86->86/tcp
- Check related error information by docker-compose log-f:
fpm_1 | [03-Dec-2019 03:57:50] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:57:50] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:57:50] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:57:50] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:57:50] ERROR: FPM initialization failed
fpm_1 | [03-Dec-2019 03:57:50] ERROR: FPM initialization failed
fpm_1 | [03-Dec-2019 03:58:51] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:58:51] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:58:51] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:58:51] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:58:51] ERROR: FPM initialization failed
fpm_1 | [03-Dec-2019 03:58:51] ERROR: FPM initialization failed
- Check the configuration information manually debugged in the container by docker diff container-id:
$ docker ps -a|grep php
5dfe26f00059 tkstorm/phpngx "nginx -g 'daemon of…" 2 weeks ago Up 41 hours 80/tcp, 0.0.0.0:86->86/tcp phpfpm_nginx_1
6f8a2044ba36 tkstorm/phpfpm "docker-php-entrypoi…" 2 weeks ago Restarting (78) 7 seconds ago phpfpm_fpm_1
- Copy the wrong
./php-fpm.d/www.conf
configuration that damaged the container to the local directory and fix it:
$ docker cp phpfpm_fpm_1:/usr/local/etc/php-fpm.d/www.conf fix-www.conf
$ vi fix-www.conf
...
slowlog = /var/log/$pool.log.slow
...
- Copy the repaired configuration to the damaged container again:
// after fix up
$ docker cp fix-www.conf phpfpm_fpm_1:/usr/local/etc/php-fpm.d/www.conf
- Restart the container:
$ docker restart phpfpm_fpm_1
// it' fix ok
$ docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------
phpfpm_fpm_1 docker-php-entrypoint php-fpm Up 9000/tcp
phpfpm_nginx_1 nginx -g daemon off; Up 80/tcp, 0.0.0.0:86->86/tcp