I have this following dockerfile:
...
ENV REMOTE_HOST abcd
RUN figlet SETTING__XDEBUG__php.ini
RUN { \
echo '[xdebug]'; \
echo 'zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so'; \
echo 'xdebug.remote_enable=1'; \
echo 'xdebug.remote_port=9000'; \
echo 'xdebug.remote_autostart=1'; \
echo 'xdebug.remote_handler=dbgp'; \
echo 'xdebug.idekey=dockerdebug'; \
echo 'xdebug.profiler_output_dir="/var/www/html"'; \
echo 'xdebug.remote_connect_back=0'; \
echo 'xdebug.remote_host='${REMOTE_HOST}; \
} >> /usr/local/etc/php/php.ini
...
As you can see, I'm starting the xdebug.remote_host
with the test 'abcd' value.
I raise the container with the following command docker run -e "REMOTE_HOST=123456" ...
After the container is working, I check the contents of php.ini this is what I have:
[xdebug]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.idekey=dockerdebug
xdebug.profiler_output_dir="/var/www/html"
xdebug.remote_connect_back=0
xdebug.remote_host=abcd
That is, xdebug.remote_host is being initialized with the abcd value passed in dockerfile, but I can not overwrite it with 123456 value passed in the container pickup process as suggested in the Overriding Dockerfile image defaults and Additionally, the operator can set any environment variable in the container by using one or more -e flags.