简体   繁体   English

Xdebug Docker 跨容器通信设置

[英]Xdebug Docker Cross Container Communication setup

I'm having an issue with multiple container / cross container Xdebug PhpStorm communication.我遇到了多容器/跨容器 Xdebug PhpStorm 通信的问题。

I have a setup with 10 containers who talk to one another but can't seem to get Xdebug working across all of them.我有一个包含 10 个容器的设置,它们相互通信,但似乎无法让 Xdebug 在所有容器中工作。

As an example: Container A makes a request to Container B which makes a request to Container C. How do I get breakpoints to stop at Container B and C ?例如:容器 A 向容器 B 发出请求,容器 B 向容器 C 发出请求。我如何获得断点以在容器 B 和 C 处停止?

At the moment I get a timeout, without Xdebug they communicate without a problem.目前我得到了超时,没有 Xdebug 他们通信没有问题。

As a side note Cross container communication is working they are in the same network and Xdebug works independently fine on each container.作为旁注,跨容器通信正在工作,它们在同一个网络中,并且 Xdebug 在每个容器上都可以独立正常工作。

This is the Xdebug config in all of my containers:这是我所有容器中的 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

Found the solution,找到了解决办法,

after a bit further digging in kind of related github issues I found this thread: https://github.com/docksal/docksal/issues/389 and this stackoverflow question: Docker / Xdebug Over LAN Server Multiple Developers在进一步挖掘了一些相关的 github 问题之后,我发现了这个线程: https : //github.com/docksal/docksal/issues/389和这个 stackoverflow 问题: Docker/Xdebug Over LAN Server Multiple Developers

Which led me to try this working configuration:这让我尝试了这个工作配置:

The final config in all of the containers is now:所有容器中的最终配置现在是:

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

HINT: You must have a different Port for each container!提示:每个容器必须有不同的端口!

eg例如

  1. Service 1 = 9006服务 1 = 9006
  2. Service 2 = 9007服务 2 = 9007
  3. Service 3 = 9008服务 3 = 9008

and so on等等

Basically using dockers internal network and using remote connect back solved it.基本上使用dockers内部网络并使用远程连接解决了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM