1

I'm using Docker Toolbox (docker-machine) in Mac OS 10.13, and trying to use Xdebug with PHP 7.1. At first I configured the interpreter via Docker container in virtual machine:

Interpreter configuration

Then I add the Server with mappings (8088 is exposed port of docker-machine):

Docker Server

And at last I create Debug Configuration:

Debug Configuration

Then I press "Start listening for Debug Connections" and trying to reload page in target project. And all I can see is infinite loader. If I switch off the listening page loads in 100 ms.

How I can use Xdebug with docker-machine?

Here is my Xdebug config from Dockerfile:

RUN echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_autostart=true" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_mode=req" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_log=/var/log/xdebug_remote.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.idekey=PHP_STORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2
  • > And all I can see is infinite loader. - Do you get anything in IDE? E.g. a breakpoint hit or a message like "Debug session finished without being paused..."? Commented Mar 30, 2020 at 19:20
  • 1) Look at the answer that George provided. 2) Ensure that PhpStorm can receive Xdebug connection on TCP 9000 port (make sure that it's PhpStorm that listens it, ensure that firewall is good here). Based on your description this should be OK already but worth double checking. 3) If still nothing, please collect Xdebug log for such unsuccessful debug session (you have it already, based on your xdebug.remote_log=/var/log/xdebug_remote.log line) and share it somewhere (do not copy-paste raw content here) -- it will tell where it tries to connect and what it tries to do. Commented Mar 31, 2020 at 9:28

1 Answer 1

2

For "Docker for Mac" you need to use the special address to connect to the host from inside the container xdebug.remote_host=host.docker.internal.

I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST

The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.

https://docs.docker.com/docker-for-mac/networking/

Not sure it's exactly the same for Docker Toolbox (docker-machine) but worth a try.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.