-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't run php-xdebug in docker(WSL2) #5277
Comments
It's happening to me too. It worked, maybe one of the latest updates broke something
I have a docker-compose file which declares the following ENV VAR
inside the WSL host I have this line in my .zshrc
So everytime I restart the WSL or reboot my computer docker-compose updates his ip correctly. This was working good until last one or two weeks I think. Now suddenly stopped working both in PHPStorm and VSCode My VSCode config is like this
|
Same situation it works correctly if I use:
remote_host's IP is the WSL2 host IP
Or any other thing that is not the literal IP it doesn't work, i get the same |
@hectorviov that is correct, you need to use the host ip, your remote is not localhost, the problem is wsl2 ip changes, in my issue the problem is it's not connecting even with that ip, I had to revert my docker for windows |
i'm having the same issue. somehow xdebug never seems to pick up on the request from the browser. I've tried setting quote-linking related issue: docker/for-win#6993 See my other comment for updates: docker/for-win#6993 (comment) |
@jakedowns I solved by fetching the ip via hostname -I and updating my config with sed something like
and this is my docker-compose snippet
|
There are no repro steps in this issue. There's a good chance it can be duped if someone can post the output of (from inside WSL2):
|
This is my output when executing the commands you've provided. Being in
In my case, the grep for the Its quite interesting that the Linux netstat lists all ports that are exposed by docker-compose containers as tcp6 bindings. Port 9000 is in LISTEN state in Windows, because I have enabled PHPStorm to "Listening for PHP Debug Connections". I am using Docker for Windows as daemon/service here, if that might be important:
I am running everything on a Windows 10 Pro:
I also do not get Xdebug working when running it in a container inside a WSL2 instance (Ubuntu 20.04). It only works when setting the So my current workaround is almost the same as already mentioned: I export an docker-compose.yml: services:
app:
build:
context: ./docker/php-fpm
args:
xdebug_remote_host: ${WSLIP} Dockerfile inside of ./docker/php-fpm:
install_xdebug.sh in ./docker/php-fpm/dev: echo "Installing XDebug..."
echo "|-> Using ${xdebug_remote_host} as xdebug.remote_host configuration."
pecl install xdebug-2.9.6 \
&& docker-php-ext-enable xdebug \
&& echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so"' > $PHP_INI_DIR/php.ini \
&& echo 'xdebug.remote_port=9000' >> $PHP_INI_DIR/php.ini \
&& echo 'xdebug.remote_enable=1' >> $PHP_INI_DIR/php.ini \
&& echo "xdebug.remote_host=${xdebug_remote_host}" >> $PHP_INI_DIR/php.ini |
I'm at a loss I can't seem to get it to work at all in PHP. I do have the site running with a reverse proxy in traefik then php running as FPM. I've been attempting to validate settings in PHPStorm as network mounted directory and as a remote server. Running hostname -I results in: 172.31.172.163 172.20.0.1 172.29.0.1 172.21.0.1 172.18.0.1 172.30.0.1 172.26.0.1 172.22.0.1 172.28.0.1 172.17.0.1 172.19.0.1 172.24.0.1 172.27.0.1 172.25.0.1 172.23.0.1 192.168.0.1 I believe 172.23.0.1 is the correct hostname (the proxy passes this as the original IP), I've tried adding this, adding all the ips comma separated, and adding all the ips with a space to no avail. PHP storm setting is set to 9090 for xdebug port. In PHP storm I simply get Target directory for validation script is not public. My PHP ini looks like this: I have confirmed used phpinfo() the extension is installed and enabled. I have port 9090 bound to port 9090 in the docker container. This appears to show up with netstat -nlt: Active Internet connections (only servers) I've attempted to shutdown both the windows firewall and UFW as well. I'm open to any suggestions having debugging would significantly increase my team's performance and most of us are using WSL2! |
/dupe #4851 |
Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! |
I tried to set up a PHP development environment in Docker in WSL 2 mode, and it does not work with Xdebug
The text was updated successfully, but these errors were encountered: