Issue
It is the configuration specific for the Docker for Mac. Normally you may define xdebug.remoteconnectback = 1, so the xdebug.remotehost is not required (which is much more convenient). Unfortunatelly Docker for Mac (due to OS X limitations) has to have xdebug.remotehost defined and the remoteconnectback is not supported. Xdebug.mode = debug,profile,trace xdebug.startwithrequest = yes xdebug.discoverclienthost = 0 xdebug.clientport = 9003 xdebug.clienthost=host.docker.internal For all options and settings available checkout the official documentation. I've tried many things trying to let work Xdebug in a Docker container. I came in contact with these resources: Setting up Xdebug with Docker Compose and WordPress image; Installing XDebug in Docker; Starting The Debugger; Zero-configuration Web Application Debugging with Xdebug and PhpStorm; Xdebug & Zend Debugger bookmarklets generator for. Apr 10, 2020 Each dev environment has its own Xdebug config. At Naept, we adopted docker-compose a few months ago. This article presents a way to configure the Docker container and VSCode to enable Xdebug, all.
XDebug can be difficult to configure with Docker due to the requirement ofremote host IP (remote_host
option) after installing XDebug and callingecho 'nxdebug.remote_enable=1' >> /usr/local/etc/php/conf.d/xdebug.ini
in your PHP image. So far I’ve encountered manual .env
variable setups.But it’s possible to obtain it automatically.
How would you do that?
Docker Compose Xdebug 3
You can use this Bash script to find the IP address more or less reliably onmost commonly used systems (Linux, Windows, Mac OS):
Docker Compose Xdebug Remote_host
It reads the IP address based on $OSTYPE
. Mac and Windows Docker versions providein-built definitions in their latest versions. Place the script in the samefolder as docker-compose.yml
and run it with regular Docker Compose parameter(s).
Then in docker-compose.yml
file you can add the following to your PHP service:
Php - PhpStorm Xdebug, WSL2, Docker ...
PHP_IDE_CONFIG
environment variable is optional and requiresAPP_XDEBUG_SERVER_NAME=server.name
in your .env
file, which allowseasier setup in PHPStorm.
Php - Setting Up Xdebug With Docker Compose And WordPress ...
As you might have noticed in the script, you can still set the IP manually in .env
if it’s not detected automatically.