duannaikuang1301 2019-05-20 15:11
浏览 144

无法让Xdebug在Ubuntu主机上使用Docker容器

I've setup Xdebug with a Docker container and a Windows host before, and thought to do something similar with my Ubuntu partition, but I can never seem to connect.

I've checked active ports and my IDE (VS Code) is listening on 9000. When I run my code, I get the following error in my XDebug log:

[16] W: Creating socket for '172.2.0.3:9000', poll success, but error: Operation now in progress (29).
[16] E: Could not connect to client. :-(

My Dockerfile:

FROM php:7.3-apache-stretch

RUN apt-get update
RUN apt-get install zip -y

RUN pecl install xdebug-2.7.0 \
    && docker-php-ext-enable xdebug
RUN touch /var/log/xdebug.log
RUN chmod 777 /var/log/xdebug.log

RUN docker-php-ext-install pdo_mysql

RUN apt-get install git -y
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
    php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
    php composer-setup.php && \
    php -r "unlink('composer-setup.php');" && \
    mv composer.phar /usr/local/bin/composer

COPY php.ini $PHP_INI_DIR/
COPY docker-php-ext-xdebug.ini $PHP_INI_DIR/conf.d/

WORKDIR /var/www/html

And my xdebug.ini:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_port=9000
; xdebug.remote_connect_back=1
; xdebug.max_nesting_level=1000
xdebug.idekey=VSCODE
xdebug.remote_host=172.2.0.3
xdebug.remote_log=/var/log/xdebug.log

I have no idea what else I can test or set to get Xdebug working.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看