xdebug不适用于Mac的Docker

在我从Docker Machine切换到Docker for Mac后,xdebug停止工作。 主机上的端口9000不能从具有xdebug的容器中访问。
php.ini

xdebug.remote_enable=1 xdebug.remote_port=9000 xdebug.remote_host=172.18.0.1 xdebug.idekey=PHPSTORM 

docker-compose.yml

 version: '2' services: php: image: <image name> ports: - 80:80 # - 9000:9000 volumes: - .:/var/www/html - ./php.ini:/usr/local/etc/php/conf.d/php.ini 

xdebug.log

 I: Checking remote connect back address. I: Checking header 'HTTP_X_FORWARDED_FOR'. I: Checking header 'REMOTE_ADDR'. I: Remote address found, connecting to 172.18.0.1:9000. E: Could not connect to client. :-( 

Нow解决我的问题?

我也有同样的问题。 这可能与OSX内的docker的限制有关。 看到这些链接。

https://docs.docker.com/docker-for-mac/networking/ https://forums.docker.com/t/explain-networking-known-limitations-explain-host/15205

也提出了可能的解决方法。 其中之一就是创build一个带有一个新的ip的设备(例如10.254.254.254),该设备可以循环回到本地主机。 当你使用这个IP作为远程主机地址,而不是由docker(127.0.0.1或172.17.0.2)分配的,它应该做的伎俩。 按照此链接编码的解决scheme

Interesting Posts