I am working in the following Dockerfile:
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
curl \
apache2 \
php5 \
php5-cli \
libapache2-mod-php5 \
php5-gd \
php5-json \
php5-mcrypt \
php5-mysql \
php5-curl \
php5-memcached \
php5-mongo \
zend-framework
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
chown www-data /usr/local/bin/composer && composer --version
# Install usefull PHP tools
RUN composer global require sebastian/phpcpd && \
composer global require phpmd/phpmd && \
composer global require squizlabs/php_codesniffer
# Install xdebug after we install composer since it cause issues
# see https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer
RUN apt-get install -y php5-xdebug
As you may notice this install PHP 5.5.x and it comes with the default configuration which I would like to override with my own values.
I have the following directory structure:
docker-php55/
├── container-files
│ ├── config
│ │ └── init
│ │ └── vhost_default
│ └── etc
│ └── php.d
│ ├── zz-php-directories.ini
│ └── zz-php.ini
├── Dockerfile
├── LICENSE
├── README.md
└── run
The files zz-php-directories.ini
and zz-php.ini
are my configurations that I should write to /etc/php5/apache2/php.ini
upon image creation. The content of the files is the following:
zz-php.ini
; Basic configuration override
expose_php = Off
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = UTC
max_execution_time = 120
; Error reporting
display_errors = stderr
display_startup_errors = Off
error_reporting = E_ALL
; A bit of performance tuning
realpath_cache_size = 128k
; OpCache tuning
opcache.max_accelerated_files = 32000
; Temporarily disable using HUGE PAGES by OpCache.
; This should improve performance, but requires appropriate OS configuration
; and for now it often results with some weird PHP warning:
; PHP Warning: Zend OPcache huge_code_pages: madvise(HUGEPAGE) failed: Invalid argument (22) in Unknown on line 0
opcache.huge_code_pages=0
; Xdebug
[Xdebug]
xdebug.remote_enable = true
xdebug.remote_host = "192.168.3.1" // this IP should be the host IP
xdebug.remote_port = "9001"
xdebug.idekey = "XDEBUG_PHPSTORM"
zz-php-directories.ini
; Configure temp path locations
sys_temp_dir = /data/tmp/php
upload_tmp_dir = /data/tmp/php/uploads
session.save_path = /data/tmp/php/sessions
uploadprogress.file.contents_template = "/data/tmp/php/upload_contents_%s"
uploadprogress.file.filename_template = "/data/tmp/php/upt_%s.txt"
How do I override the default php.ini
parameters on the image with the ones on those files upon image creation?
EDIT: Improve the question
To leave an example, zz-php.ini
is a local file placed in my laptop|PC. As soon as I install PHP in the image it comes with a default configuration file, this mean I should have a file under /etc/php5/apache2/php.ini
.
This default configuration file already has default values like for example: expose_php = On
(again this is the default, others comes as ;realpath_cache_size =
) so what I want to do is to change the value for the default file with the value from my file, in other words:
default (as in /etc/php5/apache2/php.ini) expose_php = On
override (as in zz-php.ini) expose_php = Off
At the end I should have the values from zz-php.ini
overwrited in /etc/php5/apache2/php.ini
As for the host IP address I think I could use a ENV
var and pass to the build
as an argument, I am right? If no, then how would you get the host IP address needed for that setup?