PhpStorm + Docker + Xdebug

Dear all,

I have configured a new development environment for PHP+apache. It looks like this:

Windows 10 has a docker host (inside VirtualBox) and there is a docker container for php+apache (lets name it php-apache-container). This container (php-apache-container) mounts Windows directory: c:\Users\user\Project to /var/www/html. It works, and my website is running perfectly, but the debugging (Xdebug) is somehow not working.

Actually PhpStorm doesn't allow me to map my local project to server (docker)!

I have gone through the configuration steps hundreds of times and validated xdebug configuration and everything looks fine, but the debugger doesn't stop at breakpoint. I get an error like: "Remote file path '/var/www/html/index.php' is not mapped to any file path in project"!
I have an option like "Click to set up path mappings". When I click there a new window appears with the possibilitie to define the path to my project. I define it, but the OK button is dissabled!

Do you have any ideas why I cannot map my local project to server (docker)?

Thank you in advance!

1 comment
Comment actions Permalink
In the script that starts up your Apache server inside the docker container you should set up the following which finds the IP address 
of the docker host that is running the container,

IP=$(/sbin/ip route | awk '/default/ { print $3 }')
echo "xdebug.remote_host=${IP}" >> /etc/php.d/xdebug.ini

My default xdebug.ini is:

; Enable xdebug extension module

I make sure the following packages are loaded in the container
iputils \
net-tools \
iproute \


Please sign in to leave a comment.