Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug my docker container with phpStorm

Tags:

Under the following IP my Container run successful in my Webbrowser

http://192.168.99.100:32775

I have also create a volume to share files between my container and my filesystem

docker run --name lampf -d -p 32775:80 -v /Users/sja/Sites/lamkepf2:/var/www/html --link=lampf_db:db codinglimo/apache_php540_gs_imgmck_pdflib9 

Now I install also xDebug successful in my container with the following xdebug.ini

zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"  xdebug.remote_enable=on xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.profiler_enable=0 xdebug.profiler_output_dir="/temp/profiledir" 

PHPStorm is also configured

http://img2.picload.org/image/iowdpww/xdebug.png

But my Breakpoints in my index.php are ignored? What is my mistake?

Problem is solve with help from Sergey

My new xdebug.ini

zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"  xdebug.remote_enable=on #xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_connect_back=On xdebug.remote_handler=dbgp xdebug.profiler_enable=0 xdebug.profiler_output_dir="/temp/profiledir" 
like image 796
codinglimo Avatar asked Jun 05 '15 13:06

codinglimo


People also ask

How do I debug a Docker compose file?

If you want to debug in Docker Compose, run the command Docker Compose Up using one of the two Docker Compose files as described in the previous section, and then attach using the appropriate Attach launch configuration. Launching directly using the normal launch configuration does not use Docker Compose.


1 Answers

Your Docker container can't see your PHP Storm IDE with the IP 127.0.0.1, typically the host is 172.17.42.1 from within a container. Also remote_connect_back won't work well probably. Try setting it up like this:

xdebug.remote_host=172.17.42.1  xdebug.remote_connect_back=Off 

You might need to look for a proper way to know the host's IP within your container, 172.17.42.1 is just the default but it might not always be that.

like image 175
Nicolas Cohen Avatar answered Sep 24 '22 15:09

Nicolas Cohen