pugdebug icon indicating copy to clipboard operation
pugdebug copied to clipboard

Support for xdebug within Docker container?

Open romellem opened this issue 8 years ago • 3 comments

Does pugdebug support listening to xdebug from a Docker container?

Most of the "Docker + Xdebug" tutorials you find online target PhpStorm, so I'd think that in theory I should be able to get it functioning.

This guide - http://blog.arroyolabs.com/2016/10/docker-xdebug/ - seemed decent enough to go off of, but I haven't been able to get it to work with it.

Anyone else try to get something like that setup?

romellem avatar Jan 24 '17 18:01 romellem

I do all of my work in Vagrant, so I haven't had the use case for this, but I'll try and bring up a basic docker image and try it out.

Thanks for bringing it up!

robertbasic avatar Jan 24 '17 18:01 robertbasic

For information, I get it working inside docker with the following configuration inside php.ini

       xdebug.idekey=pugdebug
       xdebug.remote_enable=1
       xdebug.remote_port=9000
       xdebug.remote_connect_back=1
       xdebug.remote_log=/tmp/php5-xdebug.log
       xdebug.remote_host=192.168.208.1 # host ip

host ip address has to be set manually. You can get it in the container with the following command

   /sbin/ip route|awk '/default/ { print $3 }'

I manage the php.ini file outside of the container, with the following mapping

services:
  php:
    image: kgtech/php7-dev
    volumes:
      - .:/var/www
      - ./docker/php.ini:/usr/local/etc/php/php.ini

kermorgant avatar May 17 '17 08:05 kermorgant

For those having problems enabling remote debugging from a docker container (like I had for about 5 hours), here's a config that works without changes:

xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.remote_autostart=0
xdebug.remote_connect_back=0

On the client side (host), use these settings:

host: 127.0.0.1
port: 9000

And make sure your docker-compose does not map port 9000:9000 at all as otherwise it won't work. Here's a docker example.

8ctopus avatar Apr 01 '20 12:04 8ctopus