I am trying to setup xdebug integration on my docker-based setup.
- I am using Docker for Mac 1.12.0-rc2-beta17 with the "native" docker machine
I have a container, with xdebug installed, exposing port 9000 and mapping it to the port 9000:
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6950c2a2b05d app "/usr/bin/supervisord" 9 minutes ago Up 9 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:9000->9000/tcp, 0.0.0.0:2222->22/tcp app_1
When I'm trying to use PhpStorm to listen to the port 9000 for debug connections, I'm getting an error "Cannot listen: port 9000 is busy".
I must precise that I'm a newbie in networks..
Firstly check your container logs to debug:
or
Add
-f
flags fortail
-like behavior:You must bind 9000 port with
--expose
option.This is the reference
if you are using docker compose sample docker-compose.yml file is here:
It dependent how you want to connect via Xdebug
xdebug.remote_connect_back=1
said that PHP will wait until a HTTP request with GET parameterXDEBUG_SESSION_START=<IDE_key>
. Then will PHP within the server try to connect back via port 9000 where your PHPStorm is listing. Classic don't call us, we will call you situation.Now your situation with docker say simple, your container is responsible for port 9000. So PHP will get a loopback and PHPStorm isn't able to use port 9000 because its already used by your docker container.
So skip the assignment of port 9000 to docker, that will fix this situation.
Two things I discovered: