我刚刚在我的机器上设置了 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 的监听正确。
在本地计算机上,我可以 telnet 到端口 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 或容器中进行操作。当我尝试时,它只是坐在那里什么都不做。然而,虚拟机和容器都可以很好地 ping 通主机。
我尝试过禁用 Mac 的防火墙,但仍然没有效果。
我不太确定如何禁用 boot2docker 虚拟机上的防火墙。
任何关于为什么这行不通的见解都将受到极大的欢迎。提前致谢。
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 开始,您可以通过静态主机名访问容器内 Mac 上托管的服务:docker.for.mac.localhost
我想从容器连接到主机上的服务?
Mac 的 IP 地址不断变化(如果您无法访问网络,则没有 IP 地址)。从 17.06 开始,我们建议连接到仅适用于 Mac 的特殊 DNS 名称 docker.for.mac.localhost,该名称解析为主机使用的内部 IP 地址。
see https://docs.docker.com/docker-for-mac/networking/#i-cannot-ping-my-containers https://docs.docker.com/docker-for-mac/networking/#i-cannot-ping-my-containers
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)