Docker Compose Xdebug



Phpstorm xdebug docker cli

Docker-compose.debug.yml
IDProjectCategoryView StatusDate SubmittedLast Update
0001877XdebugStep Debuggingpublic2020-11-02 17:562021-03-27 13:19
ReporterTomaszKaneAssigned Toderick
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionunable to reproduce
PlatformLinuxOSKDE NeonOS Version5.19
Product Version3.0.0beta1
Summary0001877: Xdebug from docker container can't connect to client
DescriptionHi,
I try to use new Xdebug on my laptop T490 with KDE Neon and PhpSorm.
Project runs on few docker containers (below config for nginx and php)
What is missing or broke with my configuration?
Steps To Reproduceinstall xdebug-3.0.0beta1via PECL and enable it (on php 7.4 fpm container)
write xdebug config:
xdebug.mode=debug
xdebug.discover_client_host=1
xdebug.cli_color=1
xdebug.html_errors=2
xdebug.var_display_max_depth = 8
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 1024
xdebug.idekey=PHPSTORM
xdebug.log=/var/log/xdebug.log
docker-compose:
version: '3'
services:
php-7.4:
build: ./docker-images/php-7.4
image: ap/php:7.4
container_name: sp-php-7.4
expose:
- '${SSH_PORT}'
ports:
- '${SSH_PORT}:22'
environment:
- X_LEGACY_GD_LIB=${X_LEGACY_GD_LIB}
- GITHUB_API_TOKEN=${GITHUB_API_TOKEN}
- TEST_RUNTIME_PATH=/tmp/runtime
volumes:
- ~/.composer-docker/cache:/root/.composer/cache:delegated
- ~/.gitconfig:/root/.gitconfig
- ${WORKSPACE_DIR}:/var/www
- ~/.ssh:/root/ssh:ro
nginx-1.19:
build: ./docker-images/nginx-1.19
image: ap/nginx:1.19
container_name: sp-nginx-1.19
depends_on:
- php-7.4
environment:
- PHP_CGI_PASS=${PHP_CGI_PASS}
ports:
- '${NGINX_PORT}:80'
- '${NGINX_SSL_PORT}:443'
volumes:
- ./vhosts:/etc/nginx/conf.d-dist
- ${WORKSPACE_DIR}:/var/www
Browser - Firefox with Cookie:
XDEBUG_SESSION=PHPSTORM
PhpStorm with config like on attached screenshos
(with mapped project root directory)
Listening is on:
$ lsof -i :9003 | grep LISTEN
java 5130 kane 23u IPv6 3040907 0t0 TCP *:9003 (LISTEN)
/etc/hosts like:
172.17.0.1 some.address.pl
Additional Informationphp -v
PHP 7.4.8 (cli) (built: Jul 9 2020 23:21:18) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
with Xdebug v3.0.0beta1, Copyright (c) 2002-2020, by Derick Rethans
xdebug log:
[6] Log opened at 2020-11-02 17:20:12.510627
[6] [Step Debug] INFO: Checking remote connect back address.
[6] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[6] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[6] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 172.22.0.1:9003.
[6] [Step Debug] WARN: Could not connect to client host discovered through HTTP headers, connecting to configured address/port: localhost:9003. :-|
[6] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[6] [Step Debug] WARN: Creating socket for 'localhost:9003', connect: Cannot assign requested address.
[6] [Step Debug] ERR: Could not connect to debugging client. Tried: 172.22.0.1:9003 (from REMOTE_ADDR HTTP header), localhost:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
[6] Log closed at 2020-11-02 17:20:12.868660
Operating SystemDebian
PHP Version7.4.0-7.4.4

Xdebug.mode = debug,profile,trace xdebug.startwithrequest = yes xdebug.discoverclienthost = 0 xdebug.clientport = 9003 xdebug.clienthost=host.docker.internal For all options and settings available checkout the official documentation. In this article, I'm going to introduce a more convenient way to quickly set up development environment with PHPStorm, Docker, Docker compose and Xdebug. The source code for docker compose configs. It is the configuration specific for the Docker for Mac. Normally you may define xdebug.remoteconnectback = 1, so the xdebug.remotehost is not required (which is much more convenient). Unfortunatelly Docker for Mac (due to OS X limitations) has to have xdebug.remotehost defined and the remoteconnectback is not supported.

Docker-compose xdebug portDebug

Phpstorm Xdebug Docker Cli

Docker Compose and Xdebug not working in PhpStorm - Stack ...

Php - Setting Up Xdebug With Docker Compose And WordPress ...

I've tried many things trying to let work Xdebug in a Docker container. I came in contact with these resources: Setting up Xdebug with Docker Compose and WordPress image; Installing XDebug in Docker; Starting The Debugger; Zero-configuration Web Application Debugging with Xdebug and PhpStorm; Xdebug & Zend Debugger bookmarklets generator for. Each dev environment has its own Xdebug config. At Naept, we adopted docker-compose a few months ago. This article presents a way to configure the Docker container and VSCode to enable Xdebug, all.