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.