Php: Why not add php.ini ?

Created on 16 Dec 2015  路  7Comments  路  Source: docker-library/php

https://github.com/php/php-src/blob/master/php.ini-production

the current docker image do not have a default php.ini.
so please add one php.ini file into image

Most helpful comment

In image php:7.0.0-fpm still are /usr/src/php/php.ini-production and /usr/src/php/php.ini-development,
but not in image php:7.0-fpm which doesn't seem to be updated anymore as it also contains outdated Docker helper scripts.

In the newer php:7.0-fpm image, the source, including the php.ini-production and php.ini-development,
is still there in an archive at /usr/src/php.tar.xz.

tar x --file=/usr/src/php.tar.xz --directory=/usr/src/  php-7.0.12/php.ini-production php-7.0.12/php.ini-development

This would extract the php.ini-* files into '/usr/src/php-7.0.12/'.

In Dockerfile:

RUN tar x --file=/usr/src/php.tar.xz --directory=/usr/src/  php-7.0.12/php.ini-production php-7.0.12/php.ini-development && \
    cp /usr/src/php-7.0.12/php.ini-production /usr/local/etc/php/php.ini

Also downloadable from php repository (tag for release 7.0.12):

All 7 comments

The current docker image don't need a default php.ini.

When there is no php.ini, default values are used, see http://php.net/manual/en/ini.core.php.

So, composer install command show errors
A php.ini file does not exist. You will have to create one.

@vitalyzhakov You maybe have mapped the default ini location to some volume, therefore deleting the default ini file.

In image php:7.0.0-fpm still are /usr/src/php/php.ini-production and /usr/src/php/php.ini-development,
but not in image php:7.0-fpm which doesn't seem to be updated anymore as it also contains outdated Docker helper scripts.

In the newer php:7.0-fpm image, the source, including the php.ini-production and php.ini-development,
is still there in an archive at /usr/src/php.tar.xz.

tar x --file=/usr/src/php.tar.xz --directory=/usr/src/  php-7.0.12/php.ini-production php-7.0.12/php.ini-development

This would extract the php.ini-* files into '/usr/src/php-7.0.12/'.

In Dockerfile:

RUN tar x --file=/usr/src/php.tar.xz --directory=/usr/src/  php-7.0.12/php.ini-production php-7.0.12/php.ini-development && \
    cp /usr/src/php-7.0.12/php.ini-production /usr/local/etc/php/php.ini

Also downloadable from php repository (tag for release 7.0.12):

Somewhat version agnostic version of the workaround:

mkdir /usr/src/php
tar --file /usr/src/php.tar.xz --extract --strip-components=1 --directory /usr/src/php
cp /usr/src/php/php.ini-production /usr/local/etc/php/php.ini

This image provides a fairly vanilla upstream-focused PHP experience, and thus uses the default upstream-provided php.ini values. If your application or use of PHP requires changes to upstream's default values, I'd recommend changing them in your derivative image or petitioning upstream to change the defaults (if you think your rationale is strong enough to convince them). Thanks!

For what it's worth, the PHP source can be more easily extracted using docker-php-source extract (and then cleaned up after use with docker-php-source delete), as the build Dockerfile itself does (and all the docker-php-ext-* scripts do): :+1:

https://github.com/docker-library/php/blob/6677546d599d3980781b520f84d03ecaad291dd1/Dockerfile-debian.template#L113
https://github.com/docker-library/php/blob/6677546d599d3980781b520f84d03ecaad291dd1/Dockerfile-debian.template#L153

Was this page helpful?
0 / 5 - 0 ratings