Search code examples
dockerphpstormxdebugboot2dockerdocker-machine

How can I debug my docker container with docker-machine and PHPStorm


I'm trying to use Xdebug with docker and docker-machine.

Here my xdebug.ini config file:

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_log=/tmp/php5-xdebug.log

Here my docker-compose.yml file:

data:
  image: busybox
  volumes:
    - ./:/srv

web:
  build: docker/nginx
  volumes_from: [data]
  links:
    - fpm
  ports:
    - "80:80"

fpm:
  build: docker/php-fpm
  volumes_from: [data]
  ports:
    - "9000:9000"

I have configured PHPStorm like this:

phpstorm config 1 phpstorm config 2

When I try to debug a page. This window appear:

phpstorm issue

If I click ok for this window, then xdebug seem to work.

If I look at the Debugger pan I can see I'm on my root page. (app.php). But PHPStorm don't highlight the current line.

current line not highlight

Is my configuration correct ?

Am I missing something ?

Thanks.


Solution

  • I finally manage to resolve this issue.

    Once you have create the server, here it's Docker

    enter image description here

    You have to create a Run/Debug configuration. Add a new PHP Remote Debug with the configured server and ide key Then click on the debug button enter image description here and it's work !

    enter image description here

    For information, the Run/Debug configuration : enter image description here