codinglimo codinglimo - 4 months ago 358
PHP Question

How can I debug my docker container with phpStorm

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"

Answer

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.