简体   繁体   English

Xdebug 3 无法从 Docker [20.10.12] 连接到 PhpStorm 调试客户端。 Ubuntu

[英]Xdebug 3 couldn't connect from Docker [20.10.12] to PhpStorm debug client. Ubuntu

So, my configurations are:所以,我的配置是:

  1. Dockerfile: Dockerfile:
FROM php:8.1-apache as php_base
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN a2enmod rewrite && install-php-extensions pgsql
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf && service apache2 restart
WORKDIR /var/www/lessor-calculator

FROM php_base as php_dev
RUN pecl install xdebug && docker-php-ext-enable xdebug
  1. docker-compose.yml: docker-compose.yml:
version: "3.4"

services:
  app:
    build:
      context: docker/server
      target: php_dev
    networks:
      my-network:
    environment:
      PHP_IDE_CONFIG: "serverName=MyApp"
    ports:
      - "${DOCKER_SERVER_PORT:-9180}:80"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./:/var/www/lessor-calculator
      - ./docker/server/apache/sites-enabled:/etc/apache2/sites-enabled
      - ./docker/server/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
      - ./docker/server/php/conf.d/xdebug.log:/var/log/xdebug.log
      - ./docker/server/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
  1. xdebug_info() output: xdebug_info() output:

xdebug_info_screenshot

  1. PhpStorm settings: PhpStorm 设置:

phpstorm_php_interpreter_screenshot

phpstorm_xdebug_settings_screenshot

  1. Xdebug log: Xdebug 日志:
[17] Log opened at 2022-01-04 14:47:45.645181
[17] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[17] [Step Debug] WARN: Creating socket for 'host.docker.internal:9003', poll success, but error: Operation now in progress (29).
[17] [Step Debug] ERR: Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(
[17] Log closed at 2022-01-04 14:47:45.649491

Also I've tried to use another port, curl host.docker.internal:9000 , with answer "Connection refused", (but just ping host.docker.internal is work fine).我也尝试使用另一个端口curl host.docker.internal:9000 ,回答“连接被拒绝”,(但只是 ping host.docker.internal工作正常)Z05B6053C41A2130AFD6FC3B158BDA.4 Everyone said, that there's no need to map 9000 port.大家都说,map 9000端口没必要。 Please any suggestion, what reason could be.请任何建议,可能是什么原因。 Thank you.谢谢你。

UPDATE: Xdebug conf:更新:Xdebug 配置:

zend_extension=xdebug

[xdebug]
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.log="/var/log/xdebug.log"

Update: new configuration for 9003 port, enable xdebug.log更新:9003 端口的新配置,启用 xdebug.log

Update 2: i'm using rootless docker更新 2:我正在使用无根 docker

Why not expose the desired port with eg.为什么不使用例如公开所需的端口。 EXPOSE 9003 in Dockerfile ?DockerfileEXPOSE 9003

xdebug ports and Dockerfile ports need to match. xdebug端口和Dockerfile端口需要匹配。

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

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