You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change common php settings via environment variable #765
There was a request to change memory_limit via environment variable: nextcloud/docker#568
There are other settings that are frequently requested to change, like the upload limit.
Is it worth to allow some common settings to be set via environment variables?
You could go for the kitchen-sink solution and just map all environment variables with a specific prefix to their corresponding php.ini settings, such as a prefix like PHP_INI_. So if I specified PHP_INI_MEMORY_LIMIT=2G, you'd have some generic code that removed the prefix, did lower case conversion of what's left, and inserted it into a php.ini, so you'd end up with memory_limit=2G.
Something like that would be pretty sophisticated I think, and given my merge request for specifically just memory limit, it would be really nice to get that in first (since it's a quick stopgap at the very least) and then replace it later with a more flushed-out and generic system (assuming that's the direction you're trying to go)
This is definitely not something I'm very keen on seeing explicitly implemented here in the php image itself -- we've already got a fair amount of "Docker-specific" behavior, and I really don't feel like it's a good idea for us to add even more (especially behavior which amounts to simply appending environment variable values directly to a .ini file verbatim, which seems pretty trivial to implement via a short script which could even be pretty easily embedded directly in the command: supplied to a PHP-based image, if needed).
Here's an example simple command/script which can be used to accomplish this pretty trivially (explicitly ignoring PHP_INI_DIR which is set in the base):
Note this won't work very well for directives which contain . (which isn't POSIX-compliant in environment variable names, so will sometimes not work appropriately).
Activity
rcdailey commentedon Dec 12, 2018
You could go for the kitchen-sink solution and just map all environment variables with a specific prefix to their corresponding php.ini settings, such as a prefix like
PHP_INI_. So if I specifiedPHP_INI_MEMORY_LIMIT=2G, you'd have some generic code that removed the prefix, did lower case conversion of what's left, and inserted it into aphp.ini, so you'd end up withmemory_limit=2G.Something like that would be pretty sophisticated I think, and given my merge request for specifically just memory limit, it would be really nice to get that in first (since it's a quick stopgap at the very least) and then replace it later with a more flushed-out and generic system (assuming that's the direction you're trying to go)
J0WI commentedon Dec 14, 2018
@yosifkit would you accept a PR implementing this?
TimWolla commentedon Dec 19, 2018
see also: TimWolla/docker-adminer#36
tianon commentedon Dec 24, 2018
This is definitely not something I'm very keen on seeing explicitly implemented here in the
phpimage itself -- we've already got a fair amount of "Docker-specific" behavior, and I really don't feel like it's a good idea for us to add even more (especially behavior which amounts to simply appending environment variable values directly to a.inifile verbatim, which seems pretty trivial to implement via a short script which could even be pretty easily embedded directly in thecommand:supplied to a PHP-based image, if needed).tianon commentedon Dec 31, 2018
Here's an example simple command/script which can be used to accomplish this pretty trivially (explicitly ignoring
PHP_INI_DIRwhich is set in the base):Note this won't work very well for directives which contain
.(which isn't POSIX-compliant in environment variable names, so will sometimes not work appropriately).Alternatively (and more supportably long-term IMO), take advantage of
php.iniexplicitly supporting environment variables (https://secure.php.net/manual/en/configuration.file.php#example-36) with something simpler (and much more explicit) like this:Thijs-Riezebeek commentedon Mar 6, 2019
For future reference,
man phphas the following to say:So you could also use the
-doption to increase INI settings, such as the memory limit: