xdebug无法在Docker Desktop for Mac中使用

Shu*_*xey 8 macos xdebug docker docker-for-mac docker-desktop

在我从Docker Machine切换到适用于Mac的Docker Desktop之后,xdebug已停止工作.9000主机上的端口无法通过xdebug从容器中访问.
php.ini:

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=172.18.0.1
xdebug.idekey=PHPSTORM
Run Code Online (Sandbox Code Playgroud)

docker-compose.yml:

version: '2'
services:
  php:
    image: <image name>
    ports:
      - 80:80
    # - 9000:9000
    volumes:
      - .:/var/www/html
      - ./php.ini:/usr/local/etc/php/conf.d/php.ini
Run Code Online (Sandbox Code Playgroud)

xdebug.log:

I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.18.0.1:9000.
E: Could not connect to client. :-(
Run Code Online (Sandbox Code Playgroud)

Н要解决我的问题?

Dan*_*you 9

我也有同样的问题.它可能与OSX中docker的局限性有关.请参阅这些链接.

https://docs.docker.com/docker-for-mac/networking/ https://forums.docker.com/t/explain-networking-known-limitations-explain-host/15205

还提出了可能的解决方法.其中之一是创建一个带有新ip的设备(例如10.254.254.254),它会循环回到localhost.然后,当您使用此ip作为远程主机地址而不是docker(127.0.0.1或172.17.0.2)分配的地址时,它应该可以解决问题.请点击此链接 获取编码解决方案

  • 谢谢.您发布的要点(https://gist.github.com/ralphschindler/535dc5916ccbd06f53c1b0ee5a868c93)运作正常. (3认同)