Xdebug (inside Docker container) ignoring XDEBUG_CONFIG environment variable
I had the same problem. My image was based on nimmis/alpine-apache-php7/
. I found that the image was using supervisor
to start processes. supervisor
has no knowledge of the Docker environment variables.
The convention to tell supervisor
that a process needs to be run, is to create a run
script at /etc/sv/{process}/run
. A script like this was used to start Apache. I needed to change the script so that it would import Docker environment variables before starting Apache.
The docs for the base image explain the convention for importing Docker environment:
If you need environment variables from the docker command line (-e,--env=[]) add
source /etc/envvars
before you use them in the script file
So I created my own custom run
script for Apache — I added source /etc/envvars
just before execution of httpd
.
I overwrote the original run
script, by adding a simple COPY
to my Dockerfile:
COPY apache-run.sh /etc/sv/apache2/run
This successfully ensured that my $XDEBUG_CONFIG
was visible to httpd
at the time it was launched. I was able to confirm that this affected my PHP configuration, by printing phpinfo();
in a webpage.
Did you do a phpinfo();
? That should tell you the settings used.
I had the same problem... took me forever to figure out. Are you using xdebug.remote_connect_back=1
? If so remove that line.
My nginx proxy was forwarding an IP through (which was wrong) and so the ip set in XDEBUG_CONFIG was being ignored.
For me it was a different problem using the official PHP-FPM-Alpine docker image (FROM php:7-fpm-alpine
)
I needed to add the XDEBUG-CONFIG to the fpm pool config:env[XDEBUG_CONFIG] = $XDEBUG_CONFIG
See full config https://github.com/attrib/docker-symfony