I have a custom docker image for apache and php7-fpm but whenever i make changes to the php ini file and use supervisord to retsart php7-fpm after those changes during image building before running the container from the image i noticed i have been unable to make php7-fpm restart. So the changes i make to the php ini file never gets reflected

But when i log into the running container and try to retsart php7-fpm then i see those changes

Here is what my supervisord config has


command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm/php-fpm.conf

command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"

Here is my start.sh script

set -e
echo "ServerName localhost" >> /etc/apache2/apache2.conf
#echo "export HOSTNAME=$(hostname)" >> /etc/apache2/envvars
sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;short_open_tag = Off/short_open_tag = On/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;display_errors = Off/display_errors = On/g" /etc/php/7.0/fpm/php.ini
sed -ri 's/^upload_max_filesize\s*=\s*.+/upload_max_filesize = 450M/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^max_input_time\s*=\s*.+/max_input_time = 300/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^memory_limit\s*=\s*.+/memory_limit = 640M/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^post_max_size\s*=\s*.+/post_max_size = 450M/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^max_execution_time\s*=\s*.+/max_execution_time = 300/g' /etc/php/7.0/fpm/php.ini
sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php/7.0/fpm/php-fpm.conf
sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.max_children = 5/pm.max_children = 9/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.start_servers = 2/pm.start_servers = 3/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.max_requests = 500/pm.max_requests = 200/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/;clear_env = no/clear_env = no/g" /etc/php/7.0/fpm/pool.d/www.conf

Please help with how to restart php7-fpm when changes are made to the php ini file with a start.sh script while creating the docker image


You may be wondering why do i need to restart php7-fpm if it only needs to be started, well no way to get php7-fpm to work with docker except i actually start it first in my docker file like below. Whenever i remove that line from my dockerfile, it does not work. If anyone has apache 2.4 and php7-fpm setup in docker that works without that way PLEASE send me the link to their image!

RUN service php7.0-fpm start



just added this line to the start.sh script

service php7.0-fpm restart

and just like that all issues got resolved!

Didn't realize it was as easy as just adding a bash command to the start.sh script

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.