gpt4 book ai didi

php - Xdebug Docker跨容器通信设置

转载 作者:行者123 更新时间:2023-12-02 19:57:52 25 4
gpt4 key购买 nike

我在使用多个容器/跨容器Xdebug PhpStorm通信时遇到问题。

我有一个带有10个容器的安装程序,这些容器可以互相通信,但似乎无法让Xdebug在所有容器中正常工作。

举个例子:
容器A向容器B发出请求,容器B向容器C发出请求。
如何获得断点以在容器B和C处停止?

目前,我超时了,没有Xdebug,他们可以毫无问题地进行交流。

附带说明,跨容器通信在同一网络中进行,而Xdebug在每个容器上均可以独立正常运行。

这是我所有容器中的Xdebug配置:

xdebug.remote_port=9006
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_host=10.254.254.254
xdebug.idekey=PHPSTORM

最佳答案

找到了解决方案,

在进一步研究了相关的github问题后,我发现了这个线程:
https://github.com/docksal/docksal/issues/389
和这个stackoverflow问题:
Docker / Xdebug Over LAN Server Multiple Developers

这使我尝试了这种工作配置:

现在,所有容器中的最终配置为:

xdebug.remote_port=[PORT]
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_host=10.254.254.254
xdebug.idekey=PHPSTORM

提示:每个容器必须具有不同的端口!

例如
  • 服务1 = 9006
  • 服务2 = 9007
  • 服务3 = 9008

  • 等等

    基本上使用dockers内部网络并使用远程连接可以解决该问题。

    关于php - Xdebug Docker跨容器通信设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56711418/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com