1

My IDE is IntelliJ and it is configured and working with Xdebug and PHP 5.6.

It is working in my host machine (MacOS) but when I turn on the Docker, the debug process fails.

If I try to expose the port 9000 (docker run -p 80:80 -p 9000:9000 ...) when I run the image I get an error inside IntelliJ -> port 9000 is in use.

If I do not expose the port 9000, I get nothing inside IntelliJ,

Here is part of the php.ini inside docker: that shows that xdebug is enabled.

[xdebug]
zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

enter image description here

What I am doing wrong?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
IgorAlves
  • 5,086
  • 10
  • 52
  • 83
  • **1)** *"If I try to expose the port 9000"* What for? Please check xdebug documentation first. It's xdebug that connects to IDE and not other way around. By exposing this port in Docker you prevent IDE from listening on it. **2)** `xdebug.remote_host=localhost` -- why `localhost`? Same -- https://xdebug.org/docs/remote -- it has to be an IP of the computer where IDE is running (as seen from inside Docker container). **In general** -- search this site using `phpstorm` + `xdebug` + `docker` tags .. or get some related manual for PhpStorm (same config logic). – LazyOne Nov 18 '17 at 14:41
  • You are right. I performed all changes and still not working. My guess is that the xdebug is not finding the intelliJ inside the host. Maybe it is seeking inside the docker – IgorAlves Nov 24 '17 at 16:47
  • That must be just wrong IP issue -- you MUST specify **correct IP** for `xdebug.remote_host` and have IDE listening on xdebug port in host OS. Xdebug does not "search" for anything (well, in case of `connect_back` option it does check set of standard request headers that may contain an IP .. (so word "searching" can be used here) but in Docker case they will have little to no useful info). – LazyOne Nov 24 '17 at 17:07
  • As I have suggested -- go through https://stackoverflow.com/questions/tagged/phpstorm+xdebug+docker results , e.g. the most recent https://stackoverflow.com/a/47450391/783119 -- you can check his final solution. Or this one -- https://stackoverflow.com/a/46265103/783119 where OP talks about settings up the right IP... – LazyOne Nov 24 '17 at 17:11

0 Answers0