Closed rafatwork closed 5 years ago
Friendly reminder.
I have very similar problem. For one project xDebug works good, for second one - only from console. As I compared setup, the only things which differs is xdebug.remote_host value. For working project it is set to:
xdebug.remote_host => docker.for.win.localhost
When value is set by docker (in my case) to:
xdebug.remote_host => 172.20.0.1
it doesn't work.
What is strange - remote host value is different when checking via cli (php -i
) and via browser (phpinfo()).
Php setup (when checking in cli via php -i
):
test.txt
Php setup (when checking via browser): phpinfo.html.txt
Docker setup: docker-compose.yml.txt
I've checked /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini, it contains:
xdebug.remote_host=docker.for.win.localhost
Also tried to setup loopback interface as described here: https://docs.amazee.io/tools/xdebug.html#xdebug-in-windows, but still not working.
I'm using Win10 with docker:
@gugalamaciek just remove this line and the debugger (xdebug) should work again after a restart of the containers.
After that change xdebug worked again. But we use Mac and not Windows.... hope this helps.
I've updated my Docker installation to version 18.06.1-ce-win73 (19507).
xdebug.remote_host
now has docker.for.mac.localhost
as value.
Pinging docker.for.mac.localhost [62.138.238.45] with 32 bytes of data:
Reply from 62.138.238.45: bytes=32 time=27ms TTL=250
Reply from 62.138.238.45: bytes=32 time=27ms TTL=250
Reply from 62.138.238.45: bytes=32 time=26ms TTL=250
Assistance greatly appreciated. This is hindering me quite a lot & I have to resort to different local development environments for the time being.
After digging this into myself, I finally found the issue. My initial suspicions were right: the xdebug.remote_host
setting is incorrect on my installation.
Executing ipconfig /all
in the command prompt I see the following:
Ethernet adapter vEthernet (DockerNAT):
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
Physical Address. . . . . . . . . : 00-15-5D-F4-68-2F
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.0.75.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
Meaning my docker host is running on the 10.0.75.1
IP address.
When testing in a container, docker.for.mac.localhost
however resolves to 62.138.238.45
. Actually, everything resolves to that IP address (*.*
, such as whatever.whatever
). This means xdebug isn't able to connect to my host.
In https://github.com/amazeeio/lagoon/blob/master/images/php/fpm/entrypoints/60-php-xdebug.sh I found out you can set the xdebug.remote_host
setting by configuring a DOCKERHOST environment variable, which is what I did:
x-environment:
...
&default-environment
...
DOCKERHOST: 10.0.75.1
...
... et voila, xdebug is working again.
I'm not a Docker expert, so any help as to why DNS resolving on my docker installation seems to be broken is more then welcome...
On Linux (Ubuntu 18.04), *.localhost
resolves to 127.0.0.1
. This means that my docker remote host is always set to docker.for.mac.localhost
, which resolves to 127.0.0.1
. The detection in https://github.com/amazeeio/lagoon/blob/master/images/php/fpm/entrypoints/60-php-xdebug.sh does not take this into account.
Setting DOCKERHOST
to the default gateway works, but this is a workaround, and this IP address might change, so it needs to be adjusted.
The same issue on MacOS. After setting DOCKERHOST: 172.16.172.16 xdebug is working agian.
@twerthmueller thank you very much! :) That works for me.
seems like this has been solved, thanks everybody!
@Schnitzel Unless I'm missing something, but I think this hasn't been solved. We only have a workaround.
Yes, I still have this issue as well.
Instead of the current logic, it should try host.docker.internal
. That will take care of macOS and Windows. If that host cannot be resolved, then the script should get the gateway for Linux.
@tamasd The logic works correctly - it tries its best to resolve the host, but times out. see https://github.com/amazeeio/lagoon/issues/1088
@VladBo same here, 172.16.172.16 works. @AlexSkrypnyk @Schnitzel
I am not sure I understand this issue. https://github.com/amazeeio/pygmy/blob/267ba143158548628f190f05ecb5cb2c19212038/lib/pygmy/resolv_osx.rb#L26
I still have this issue https://github.com/uselagoon/lagoon/pull/2002
host.docker.internal doesnt resolve.
`nslookup host.docker.internal Server: 192.168.0.1 Address: 192.168.0.1#53
** server can't find host.docker.internal: NXDOMAIN`
docker desktop: 4.0.0 (67817) macOs: 11.5.2 (20G95) Big Sur
@iijiang I've recently tested xdebug in our latest images and they are working correctly. Can you please follow our setup instructions and go through all the troubleshooting steps? If it still doesn't work, please open a new issue or discussion (a lot of people turn off notifications for already closed issues).
Describe the bug I can't get xdebug to work on my local machine. Everything looks correct + using the chrome debug extension (and I can see that the cookie is being set). In phpinfo() I notice that "xdebug.remote_host" is set to 192.168.0.1. Is this correct? If not, how do you change this value?
phpStorm configuration
docker-compose.yml docker-compose.txt
phpinfo phpinfo.html.txt
Additional info Running Windows 10 - 1803 OS Build 17134.165 Running Docker CE 17.12.0-ce-win47 (15139)