title: Xdebug Netbeans Php Docker
body: <p>I start through browser via <code>http://dev.app/?XDEBUG_SESSION_START=netbeans-xdebug</code>and best I could get is page holds, execution is halted, but Netbeans doesn't stop on breakpoint but keeps waiting for connection. That's when I set proxy in Netbeans on 127.0.0.1:10000. </p>
  
  <p>It makes more logic to put there ip of docker machine 192.168.99.100 but then page is just loaded, nothing stops (docker toolkit on win 8.1). Also when I leave out proxy in Netbeans nothing stops. </p>
  
  <p>When something is listening on 10000 execution is halted where I put breakpoint but Netbeans is waiting for connection. Xdebug is installed and listed in <code>php -v</code> and <code>php -m</code>.I did expose port 10000.</p>
  
  <p>Debugger port, project url and session id are set in Netbeans.</p>
  
  <p>Xdebug <a href="https://xdebug.org/docs/remote" rel="nofollow">docs</a> say when you set <code>xdebug.remote_connect_back=1</code> you don't need to specify remote host.</p>
  
  <p>I use xdebug.ini from <a href="https://github.com/prooph/docker-files/blob/master/php/config/xdebug.ini" rel="nofollow">here</a> used by this <a href="https://github.com/prooph/docker-files/blob/master/php/7.0-fpm-xdebug" rel="nofollow">container</a></p>
  
  <pre><code>zend_extension=xdebug.so
  xdebug.default_enable=1
  xdebug.remote_enable=1
  xdebug.remote_handler=dbgp
  ; port 9000 is used by php-fpm
  xdebug.remote_port=10000
  xdebug.remote_autostart=0
  ; no need for remote host
  xdebug.remote_connect_back=1
  xdebug.idekey="netbeans-xdebug"
  </code></pre>
  
  <p><code>docker-compose.yml</code></p>
  
  <pre><code>php-fpm:
      build:
          context: ./php-fpm
          dockerfile: Dockerfile-70
      volumes_from:
          - application
      expose:
          - "9000"
          - "10000"
      ports:
          - "10000:10000"
      links:
          - workspace
      environment:
          PHP_IDE_CONFIG: "serverName=dev.app"
  
  nginx:
      build: ./nginx
      volumes_from:
          - application
      volumes:
          - ./logs/nginx/:/var/log/nginx
      ports:
          - "80:80"
          - "443:443"
      links:
          - php-fpm
  </code></pre>
  
  <p>Edit: Here is the xdebug.log when I listen on 192.168.99.1:10000 in Netbeans, execution holded but nb still waiting connection. Win firewall disabled. I did stopping debug from nb.</p>
  
  <pre><code>Log opened at 2016-05-26 09:38:04
  I: Checking remote connect back address.
  I: Checking header 'HTTP_X_FORWARDED_FOR'.
  I: Checking header 'REMOTE_ADDR'.
  I: Remote address found, connecting to 192.168.99.1:10000.
  I: Connected to client. :-)
  -&gt; &lt;init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/x
  debug" fileuri="file:///var/www/laravel/public/index.php" language="PHP" xdebug:
  language_version="7.0.6" protocol_version="1.0" appid="6" idekey="netbeans-xdebu
  g"&gt;&lt;engine version="2.4.0"&gt;&lt;![CDATA[Xdebug]]&gt;&lt;/engine&gt;&lt;author&gt;&lt;![CDATA[Derick Re
  thans]]&gt;&lt;/author&gt;&lt;url&gt;&lt;![CDATA[http://xdebug.org]]&gt;&lt;/url&gt;&lt;copyright&gt;&lt;![CDATA[Cop
  yright (c) 2002-2016 by Derick Rethans]]&gt;&lt;/copyright&gt;&lt;/init&gt;
  
  -&gt; &lt;response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/db
  gp/xdebug" status="stopping" reason="ok"&gt;&lt;/response&gt;
  
  Log closed at 2016-05-26 09:38:25
  
  root@b42a5193d501:/tmp#
  </code></pre>
  
  <p>Edit2: </p>
  
  <p>Xdebug binds outside the vm, php socket does <a href="http://image.prntscr.com/image/de176b3ee0ad471496ddb83e48e51e80.png" rel="nofollow">connect</a>, it's about Netbeans not sending proper data. <a href="http://image.prntscr.com/image/29e0eb1be85e49998fc831fe11dcc291.png" rel="nofollow">Path mapping</a> in Netbeans.</p>
  
  <p>Idea how to debug? Wireshark?</p>
  
  <p>And this is netstat when debugging is started and Netbeans is waiting for connection</p>
  
  <pre><code>C:\Windows\System32&gt;netstat -np TCP | find "10000"
    TCP    192.168.99.1:10000     192.168.99.1:57084     ESTABLISHED
    TCP    192.168.99.1:10000     192.168.99.100:55650   ESTABLISHED
    TCP    192.168.99.1:57084     192.168.99.1:10000     ESTABLISHED
  </code></pre>
  
  <p>This is netstat inside vm machine</p>
  
  <pre><code>docker@default:~$ sudo netstat -plnt | grep ':10000'
  tcp        0      0 :::10000                :::*                    LISTEN
  </code></pre>
  
  <p>Also <code>telnet ::1 10000</code> connects, and <code>telnet 192.168.99.1 10000</code> or <code>telnet 192.168.99.100 10000</code> do not, so I think I located the problem, docker vm is expecting connection on :1 ip6 which is strange because i disabled it on whole windows?</p>