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 host.dev) 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.

Version

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 debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=0
;xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.remote_port=9001
xdebug.remote_host=localhost
xdebug.idekey=PHPSTORM

xdebug.remote_log="/tmp/xdebug.log"


Accordingly, the port 9001 proposed from the container to the host machine.
Here is part of php configuration container in docker-compose.yml
php:
build:
 context: ./docker/containers/php
 dockerfile: Dockerfile-dev
volumes:
 - ./:/var/www/html
 - ./docker/containers/php/config/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
ports:
 - "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, 0.0.0.0:9001->9001/tcp

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

Now, I need my local machine podklyuchaetsya to Xdebug host.dev.
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 https://help.ubuntu.com/community/SSH/OpenSSH/Port...
According to the same manual I got the following
ssh -R 9001:localhost:9001 user@host.dev
After this command, as I understand it, the port 9001 with the host.dev 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
1c9e918cb38f4b068a4203725d3a30d3.png
2. Configured DBGp Proxy
353b0ee8731f4dd990caaa6e5384df51.png
3. Configured remote server by mapping local and remote directory
65bc76b5af3941fa977cc5ec59cac071.png
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
15dfe7c73fdc4a25a100f97a6d4537ee.png
5. Next, choose a configuration, and begin to wait for the debug session
33ac2be675b34e66bc19837c21c8e473.png
Everything seems logical and correct.

And finally in the browser installed Xdebug Helper for Chrome in which enabled debug
141cbee88f564c00832766e1f56206a6.png

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

Find more questions by tags DockerPHPXdebug