I have an nginx container and a php-fpm container running together as my web server. I connect to it through a container running jwilder/nginx-proxy that exposes port 80. On beta8, xdebug was able to connect back to PhpStorm running on my Mac host. With beta9, it cannot.
As a temporary workaround, I’ve setup another loopback IP on my host:
sudo ifconfig lo0 alias 10.254.254.254
And in php.ini, I’ve set:
xdebug.remote_host=10.254.254.254
Is there another way to make this work besides setting up the new global IP address? Is there an address that services running in containers can use to reach back to the host?
Expected behavior
When xdebug.remote_connect_back=1 in php.ini, xdebug connects back to the Mac rather than to itself.
Actual behavior
The xdebug logs report:
Log opened at 2016-04-29 02:12:12 I: Checking remote connect back address. I: Checking header 'HTTP_X_FORWARDED_FOR'. I: Remote address found, connecting to 172.17.0.1:9090. E: Could not connect to client. :-( Log closed at 2016-04-29 02:12:12
Information
$ pinata diagnose -u OS X: version 10.11.4 (build: 15E65) Docker.app: version v1.11.0-beta9 Running diagnostic tests: [OK] docker-cli [OK] Moby booted [OK] driver.amd64-linux [OK] vmnetd [OK] osxfs [OK] db [OK] slirp [OK] menubar [OK] environment [OK] Docker [OK] VT-x Docker logs are being collected into /tmp/20160428-222036.tar.gz Most specific failure is: No error was detected Your unique id is: DE98ED6A-CF8C-42C0-B387-CB3A5C604478 Please quote this in all correspondence.
Same here! Works perfect when I’m running docker on a VM. But now it doesn’t work for any ip when i run docker for mac. I install the xdebug in my container running the php server. Else it’s working very well so far!
Same issue here. I was able to connect to PHPStorm on 172.17.42.1 but it was amazingly slow. 172.17.0.1 doesn’t work at all. However, I have the same problem with docker-machine so I guess it’s not a problem specific to the docker for mac beta. I run 1.11.1 on both docker-machine and osx.
I can confirm this is still an issue with beta13.1. Using jbrinley’s loopback workaround does work so at least this is possible.
As stated you need to run on your host:
sudo ifconfig lo0 alias 10.254.254.254
Then in your php.ini: xdebug.remote_host=10.254.254.254 xdebug.remote_connect_back = 0
The remote_connect_back must be disabled for remote_host to be used.
OS X: version 10.11.5 (build: 15F34)
Docker.app: version v1.11.1-beta13.1
Running diagnostic tests:
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160531-112333.tar.gz
Most specific failure is: No error was detected
Your unique id is: 80AF3F1D-B9D8-4F5A-A209-BEA8649FE954
As mentioned in my original post, I’m connecting to my containers via jwilder/nginx-proxy. I’ve found that a tweak there makes this slightly less cumbersome.
You still have to setup the loopback IP:
sudo ifconfig lo0 alias 10.254.254.254
And in the proxy’s config (mapping a local file onto /app/nginx.tmpl), I change
Also seeing the issue on Docker for Mac version 1.12.0-rc2. I can get it to work by setting the xdebug.remote_host to the internal IP on my Macbook, but that’s not ideal since it requires a manual step. It would be nice to be able to use the gateway IP, b/c that could be scripted in the Dockerfile.
Try IP from here as xdebug.remote_host : cat /Users/<YOUR_USERNAME>/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/slirp/host
I set the xdebug.remote_host and set PhpStorm to listen for connections but still not seeing anything. The new xdebug settings show up in a phpinfo page, so they are defiantly in effect.
I have got it working with following configuration:
; xdebug options for HHVM/PHP
xdebug.enable=1
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
xdebug.remote_host="192.168.1.5" ; My local network IP, which is accessiable inside the container
xdebug.remote_port=9089
# NGINX config, set this where you have put other FastCGI configuration
fastcgi_param REMOTE_ADDR "192.168.1.5"; #My local network IP
Make sure to restart the containers after these.
Now goto PHPStorm Preferences -> Languages and Frameworks -> PHP -> Debug:
In the Xdebug section, set Debug port to 9089 and Can accept external connections should be checked. Now, click on the phone icon in top right corner in PHPStorm that has caption of Start listening for PHP debug connections.
You may want to restart PHPStorm and should have XDebug Helper installed and its IDE Key set to PHPSTORM.
+1. I’ve tried unsuccessfully to make it work with 1.12.0-rc3 using the internal container IP where connections come from - 172.19.0.1. The solution using the local IP address works but is extremely annoying when working from several different places and changing IP.