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

  • Does docker reuse images when multiple containers run on the same host?
  • ECS Agent starting Docker container doesn't complete. Manual start successful
  • Docker Networking
  • Docker workflow for scientific computing
  • Confused about Docker -t option to Allocate a pseudo-TTY
  • Backup stateful docker volume
  • 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.