php-Xdebug无法连接回Docker主机

我刚刚在机器上安装了Docker&有一个Nginx / PHP7(FPM)/ MySQL设置都可以正常工作,但是在PHP容器上安装了Xdebug后,我无法将其连接回主机上的PHPStorm.

这是我的PHP Xdebug配置…

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-
20151012/xdebug.so
xdebug.remote_log=/usr/local/var/log/xdebug.log
xdebug.remote_enable=1
xdebug.remote_host=192.168.99.1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

浏览时,通过为容器设置Xdebug启用cookie,不会提示建立连接.如果我浏览本地托管的站点,则存在,所以我知道PHPStorm的侦听正确.

在本地计算机上,我可以远程登录到端口9000…

$telnet 192.168.99.1 9000
Trying 192.168.99.1...
Connected to 192.168.99.1.
Escape character is '^]'.
^]
telnet> quit
Connection closed.

…但是我无法从boot2docker VM或容器中获取.当我尝试时,它只是坐在那里什么都不做.但是,VM和容器都可以ping通主机.

我曾尝试禁用Mac的防火墙,但仍然不满意.

我不太确定如何在boot2docker VM上禁用防火墙.

我们将非常欢迎您提供任何对此为何行不通的见解.提前致谢.

最佳答案
Xdebug建议在容器内配置:

zend_extension = xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_host = docker.for.mac.localhost
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.remote_autostart = 1
xdebug.idekey = PHPSTORM

从Docker-17.06开始,您可以通过静态主机名访问Container内Mac上托管的服务:docker.for.mac.localhost

I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST ?
The Mac has a changing IP address (or none if you have no network access). From 17.06 onwards our recommendation is to connect to the special Mac-only DNS name docker.for.mac.localhost which resolves to the internal IP address used by the host.

查看https://docs.docker.com/docker-for-mac/networking/#i-cannot-ping-my-containers

相关文章

最近一直在开发Apworks框架的案例代码,同时也在一起修复Apw...
最近每天都在空闲时间努力编写Apworks框架的案例代码WeText。...
在《Kubernetes中分布式存储Rook-Ceph部署快速演练》文章中,...
最近在项目中有涉及到Kubernetes的分布式存储部分的内容,也...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...