How to set PHP memory limit and max execution time in your Dockerfile

If you want to set the PHP memory limit and/or max execution time to something other than the default, you can do this in your container during build. Use following in your Dockerfile:

The RUN commands above will copy the default production ini file, and then will modify the memory_limit and set it to 4 gigabytes in the ini file. It also sets the max_execution_time to zero, meaning there is no max.