Docker – port prevents listening

I am trying to setup xdebug integration on my docker-based setup.

I must precise that I’m a newbie in networks..

  • Why does using DOCKER_OPTS=“--iptables=false” break the DNS discovery for docker-compose?
  • Nginx fail on Docker deployment to Amazon
  • Container already stopped error on ECS
  • How to access a docker container running on MacOSX from another host?
  • Why can't I extend docker postgres image to create extra database and user
  • error when run docker
  • 3 Solutions collect form web for “Docker – port prevents listening”

    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 parameter XDEBUG_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.

    Firstly check your container logs to debug:

    docker logs 6950c2a2b05d
    

    or

    docker logs app_1
    

    Add -f flags for tail-like behavior:

    docker logs -f app_1
    

    Two things I discovered:

    • There is no need to expose the port 9000 on a container with xdebug (that seems rather counter-intuitive for me, as I do not exactly understand how my IDE connects to xdebug then).
    • I was able to use xdebug using the workaround described in https://forums.docker.com/t/ip-address-for-xdebug/10460/4.
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.