简体   繁体   English

Docker容器与Docker主机xdebug冲突

[英]Docker container and docker host xdebug conflict

I have a PHP-FPM docker container (php 7.2) with a service exposing REST API inside and xdebug 2.6 installed in the container. 我有一个PHP-FPM泊坞窗容器(php 7.2),其中包含暴露REST API的服务,并且在容器中安装了xdebug 2.6。 This is the xdebug config: 这是xdebug配置:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_host=hostmachine

Now I also have xdebug installed at the docker host, that is my desktop. 现在,我还在Docker主机上安装了xdebug。 And I'm trying to debug an API client on the docker host. 我正在尝试在Docker主机上调试API客户端。 The client connects to the container exposing the API. 客户端连接到公开API的容器。 Everything hangs after sending a request from the API client to the container. 从API客户端向容器发送请求后,一切都将挂起。

In the following code sample the assignment $test=1 is never executed if my IDE is listening for incoming debugger connections (no debug configs selected), everything hangs after stepping into $response = $this->httpClient->get('info') ( $httpClient is guzzle http 6.3 btw): 在下面的代码示例中,如果我的IDE正在侦听传入的调试器连接(未选择调试配置),则永远不会执行分配$test=1 ,进入$response = $this->httpClient->get('info')$httpClient http 6.3 btw):

public function getInfo(): InfoInterface
    {
        $response = $this->httpClient->get('info');
        $test = 1;
    }

I was thinking that the xdebug in the container is trying to connect to my IDE, that's the reason of the hanging. 我当时以为容器中的xdebug试图连接到我的IDE,这就是挂起的原因。 But then how can I debug my API client without the container's xdebug interference? 但是,如何在没有容器的xdebug干扰的情况下调试API客户端呢?

我应该为docker容器使用不同的端口进行连接,并且/或者增加IDE中的最大调试连接,这是针对原始问题的前两个注释中建议的。

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

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