加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

php-Xdebug无法连接回Docker主机

发布时间:2020-12-16 03:24:30 所属栏目:安全 来源:网络整理
导读:我刚刚在机器上安装了Docker有一个Nginx / PHP7(FPM)/ MySQL设置都可以正常工作,但是在PHP容器上安装了Xdebug后,我无法将其连接回主机上的PHPStorm. 这是我的PHP Xdebug配置… zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdeb

我刚刚在机器上安装了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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读