簡體   English   中英

Xdebug 3 無法從 Docker [20.10.12] 連接到 PhpStorm 調試客戶端。 Ubuntu

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

所以,我的配置是:

  1. 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:
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_screenshot

  1. PhpStorm 設置:

phpstorm_php_interpreter_screenshot

phpstorm_xdebug_settings_screenshot

  1. 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

我也嘗試使用另一個端口curl host.docker.internal:9000 ,回答“連接被拒絕”,(但只是 ping host.docker.internal工作正常)Z05B6053C41A2130AFD6FC3B158BDA.4 大家都說,map 9000端口沒必要。 請任何建議,可能是什么原因。 謝謝你。

更新: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"

更新:9003 端口的新配置,啟用 xdebug.log

更新 2:我正在使用無根 docker

為什么不使用例如公開所需的端口。 DockerfileEXPOSE 9003

xdebug端口和Dockerfile端口需要匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM