Jerry
Jerry

Reputation: 666

Xdebug Docker Cross Container Communication setup

I'm having an issue with multiple container / cross container Xdebug PhpStorm communication.

I have a setup with 10 containers who talk to one another but can't seem to get Xdebug working across all of them.

As an example: Container A makes a request to Container B which makes a request to Container C. How do I get breakpoints to stop at Container B and C ?

At the moment I get a timeout, without Xdebug they communicate without a problem.

As a side note Cross container communication is working they are in the same network and Xdebug works independently fine on each container.

This is the Xdebug config in all of my containers:

xdebug.remote_port=9006
xdebug.remote_autostart=1
xdebug.remote_enable=1  
xdebug.remote_connect_back=0 
xdebug.remote_host=10.254.254.254 
xdebug.idekey=PHPSTORM

Upvotes: 3

Views: 331

Answers (1)

Jerry
Jerry

Reputation: 666

Found the solution,

after a bit further digging in kind of related github issues I found this thread: https://github.com/docksal/docksal/issues/389 and this stackoverflow question: Docker / Xdebug Over LAN Server Multiple Developers

Which led me to try this working configuration:

The final config in all of the containers is now:

xdebug.remote_port=[PORT]
xdebug.remote_autostart=1
xdebug.remote_enable=1  
xdebug.remote_connect_back=0 
xdebug.remote_host=10.254.254.254 
xdebug.idekey=PHPSTORM

HINT: You must have a different Port for each container!

e.g.

  1. Service 1 = 9006
  2. Service 2 = 9007
  3. Service 3 = 9008

and so on

Basically using dockers internal network and using remote connect back solved it.

Upvotes: 3

Related Questions