How to properly configure xdebug.client_host for Docker in Linux?

Viewed 2473

I am running a PHP server inside a Docker container on Linux (WSL2). I would like to connect Xdebug to this process, but can't find out which IP to use for this.

On Windows and Mac, the xdebug.idekey=host.docker.internal variable automatically maps the correct IP, but AFAIK this isn't available in Linux.

I've tried manually inputting the IP from ip show route and hostname -I from both the host as well as the docker-container, but these don't work either (and would only be a temporary fix even if they did work). My container also does not have a docker0 network, which some tutorials want to use to connect, and I am not sure what that is or how I get one.

So the question is: how can I get the correct IP address and automatically set it in my configuration (docker-file, docker-compose or php.ini file)

0 Answers
Related