How to connect to Xdebug running in a Docker container on a remote machine?

Colleagues, please help in debugging connection from my local machine to a remote xdebug server.

Have the development server (hereafter on which the Docker container is running PHP-FPM xdebug with Linux Alpine. Since the standard xdebug port 9000 are reserved for PHP-FPM, then xdebug was allocated to the port 9001.


PHP 7.1.0 (cli) (built: Dec 27 2016 19:41:35) ( NTS )
Copyright (c) The PHP Group 1997-2016
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.1-dev, Copyright (c) 2002-2016, by Derick Rethans

Soderjamoe /usr/local/etc/php/conf.d/xdebug.inilying inside of the container, the following:
; NOTE: The actual extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)




Accordingly, the port 9001 proposed from the container to the host machine.
Here is part of php configuration container in docker-compose.yml
 context: ./docker/containers/php
 dockerfile: Dockerfile-dev
 - ./:/var/www/html
 - ./docker/containers/php/config/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
 - "9001:9001"

The output of docker ps container for php confirms the forwarding of the port.
In column PORTS in contrast to the php container - 9000/tcp,>9001/tcp

At this stage I'm supposed to be able to to connect to xdebug and work.

Now, I need my local machine podklyuchaetsya to Xdebug
But the problem is that my local machine is behind a router where the port forwarding is not working. Instead of trying to solve the problem with the router I started looking for another way and found it.

On the Internet it is recommended to use Remote Port Forwarding from SSH and it is described here
According to the same manual I got the following
ssh -R 9001:localhost:9001
After this command, as I understand it, the port 9001 with the should be zbinden on my local machine. Thus I have direct access to xdebug to your local machine.

As you know, not working :(

In the xdebug logs I see the error, but the gugleniya does not help.

Log opened at 2017-01-29 11:22:36
I: Connecting to configured address/port: localhost:9001.
W: Creating socket for 'localhost:9001', poll, success, but error: Operation in progress (29).
W: Creating socket for 'localhost:9001', poll, success, but error: Operation in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-01-29 11:22:36

My IDE PHPStorm is configured in a standard way.
1. Changed the port from Xdebug
2. Configured DBGp Proxy
3. Configured remote server by mapping local and remote directory
Since I have a multi-domain application, configured a server for one domain. How to make a universal I have found.
Please note that mine is running on port 8080. This port proposed from nginx listening to port 80 inside the Docker container to the host machine. Therefore, when setting up servers I ukazal port 8080.
4. Configured to Remote Debug a PHP project created in section 3 of the server
5. Next, choose a configuration, and begin to wait for the debug session
Everything seems logical and correct.

And finally in the browser installed Xdebug Helper for Chrome in which enabled debug

Someone knows what's the matter?
August 19th 19 at 23:08
0 answer

Find more questions by tags DockerPHPXdebug