Search code examples
phpdockerdocker-composedockerfile

how to add these settings to my php.ini in docker


I'm using docker-compose, and I want to add this setting to my php.ini

upload_max_filesize = 50M

but I'm confused I have 2 php.ini, please see the screenshot

how can I persist my additional setting to the php.ini?

Thank you in advance

enter image description here


Solution

  • Use docker cp <php_container_name>:/usr/local/etc/php/php.ini-development . to copy the ini file from the container to host. Change the settings as you like then mount the edited file into the container. In the compose file add this to your php service:

      volumes:
        - /home/user/my-edited-php.ini:/usr/local/etc/php/conf.d/my-edited-php.ini
    

    It should appear in the directory inside the containers /usr/local/etc/php/conf.d folder. This is pulled in as additional config. For editing one change the edit should be added as an additional config file. You will then not have to replace every other config option and when updates are made to the containers default ini files they will be carried over.