If you encounter a bug and something does not work, make sure you have done the following and check those boxes before submitting an issue - thank you!
docker pull cytopia/<used_docker>) before running docker-compose uplog/ directory).env setting DEBUG_COMPOSE_ENTRYPOINT=1)HOST_PATH_MYSQL_DATADIR on existing database files. Different mysql|mariadb versions might upgrade/corrupt existing database files. If you have done that already, start with a different path of HOST_PATH_MYSQL_DATADIR (to an empty directory) and try again.Please also specify the following info:
macOS Sierra 0.12.6
docker versionDocker version 18.03.1-ce, build 9ee9f40
docker-compose versiondocker-compose version 1.21.0, build 5920eb0
docker-py version: 3.2.1
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
xdebug.remote_enable=on
xdebug.remote_host=host.docker.internal
xdebug.remote_connect_back=0
xdebug.idekey=code
xdebug.remote_log=/var/log/php/xdebug.log
I'm using vscode with the following configuration
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"stopOnEntry": true,
"log": true,
"pathMappings": {
"/shared/httpd/test/htdocs": "${workspaceFolder}"
}
}
]
}
This is the contents of the container's /etc/hosts when I ./shell.sh:
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.16.238.1 docker.for.lin.host.internal
172.16.238.1 docker.for.lin.localhost
172.16.238.10 efc8e30c9f30
What happens when you ping host.docker.internal from inside the PHP container?
Edit: did you read: https://devilbox.readthedocs.io/en/latest/tutorials/enable-xdebug.html
Alternative hostnames:
Please try to ping all of them and see which ones resolve
@cytopia Thank you for looking at the issue. I get the following upon pinging the said hosts
[email protected] in /shared/httpd $ ping host.docker.internal
ping: host.docker.internal: Name or service not known
[email protected] in /shared/httpd $ ping docker.for.mac.host.internal
ping: docker.for.mac.host.internal: Name or service not known
[email protected] in /shared/httpd $ ping docker.for.mac.localhost
ping: docker.for.mac.localhost: Name or service not known
Can you find out the IP of your Docker bridge interface
This is the output when I docker network inspect the created network
[
{
"Name": "devilbox_app_net",
"Id": "13a40bc34c15ce9a12709ca055b72f2e2ae77fedb1cf5ff3b9830a01a032c326",
"Created": "2018-05-06T17:53:41.656574448Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.16.238.0/24",
"Gateway": "172.16.238.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"01777d376597c73f7be6ba59ccc1b98984e48c487de6bf8e56f41ba587427e3a": {
"Name": "devilbox_httpd_1",
"EndpointID": "c77616c823edf405957abdb90c88d480735576eaa70d6088725bf15a2adb7c52",
"MacAddress": "02:42:ac:10:ee:0b",
"IPv4Address": "172.16.238.11/24",
"IPv6Address": ""
},
"49e414632f201dcb19083c06e0af62fad21ba8a040750b01e483a99e2d0a8ad9": {
"Name": "devilbox_bind_1",
"EndpointID": "288fbe349119b5ff17e8cf3be8e07c4abe82869650a3468beb71c0a3006e21f8",
"MacAddress": "02:42:ac:10:ee:64",
"IPv4Address": "172.16.238.100/24",
"IPv6Address": ""
},
"efc8e30c9f30fbd74488829b66df683a226738d817807014ac9208dcf057fbe6": {
"Name": "devilbox_php_1",
"EndpointID": "139f6ac9df56173a8bb38811c78eaa067a7494ff73914ec0dbba5392a839006c",
"MacAddress": "02:42:ac:10:ee:0a",
"IPv4Address": "172.16.238.10/24",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.enable_ipv6": "false"
},
"Labels": {
"com.docker.compose.network": "app_net",
"com.docker.compose.project": "devilbox"
}
}
]
When using 172.16.238.1, can you reach services that are running on your host operating system (from inside the PHP container)?
I can't. I tried running
php -S 0.0.0.0:8080
on the host and then running
[email protected] in /shared/httpd $ curl 172.16.238.1:8080
curl: (7) Failed to connect to 172.16.238.1 port 8080: Connection refused
on the PHP container
This seems to happen on the PHP container only. When I tried pinging inside the httpd and mysql containers, I'm able to ping the host.docker.internal. I'm using PHP 7.2.
@jmcbee can you set the BIND_DNS_RESOLVER in .env to 127.0.0.11 and see if that works
I'm able to ping the host.docker.internal
To what IP does it resolve?
Hi. This was impeding on my progress so I just used another docker-based PHP dev setup. I'm sorry for troubling you.
A solution to this issue can be to have an alias on your loopback device. The method to create one is shown in the link below.
creating the alias for xdebug
Then all you have to do is configure your xdebug.ini in the devilbox/cfg/php-ini-* folder to use the alias as your remote host example below:
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.idekey="devilbox"
xdebug.remote_log=/var/log/php/xdebug.log
xdebug.remote_host=10.254.254.254
xdebug.remote_connect_back=0
also note, that in mac xdebug.remote_connect_back parameter has to be 0, so the alias can be used as remote_host
@longelas thanks for the solution. I will re-open and add this to the documentation.
I've always managed to get by without the remote host part using remote_connectback:
xdebug.cli_color = 1
xdebug.max_nesting_level = 500
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.remote_connect_back = On
xdebug.remote_enable = on
xdebug.remote_port = 9000
xdebug.show_mem_delta = 1
xdebug.var_display_max_depth = 5
@Tuurlijk is that for MacOS? (Docker for Mac or Docker Toolbox)?
This has worked for me on Mac in the past, and works for Linux in the present.
I used to use Vagrant boxen, but I can confirm that this configuration (remote_connect_back) also works for this docker setup on Linux.
I am having this same issue.
OSX 10.12.6
docker 18.03.1-ce
docker-compose 1.21.1
if i try the gateway address 172.16.238.1 in the php container, my curl just returns the devilbox status page. I am really hoping there is a fix for this (tried everything listed above and no go) because getting debugging working with PHPStorm is the 1 thing left stopping me from adopting devilbox for development.
@pvantilb for OSX you should create a network alias on localhost interface and use this for the remote_host:
xdebug.remote_host = 10.254.254.254Documentation will be ready shortly
I tried the network alias before but just for sanity sake i followed the instructions and setup the alias on the HOST for lo0 to 10.254.254.254.
Inside the PHP container, i then can ping the address fine. When i try to curl though, i still get the devilbox status page content regardless of the port used.
I run php -S 0.0.0.0:8080 on the host and it makes no difference. I tried php -S 10.254.254.254:8080 and still got the devilbox status page.
is there something in the php container that i should be doing so that it talks to the host and not the webserver container?
Michiel, I tried both with and without the remote_connect_back set to on.
and neither showed a connection to the IDE.
On Thu, Jul 19, 2018 at 3:53 AM Michiel Roos notifications@github.com
wrote:
@pvantilb https://github.com/pvantilb Can you try without specifying an
IP address? And using:xdebug.remote_connect_back = On
xdebug.remote_enable = on
xdebug.remote_port = 9000—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/cytopia/devilbox/issues/250#issuecomment-406188197,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AV5_rq_Mdg0ET-awPhXhnZf8pXO8Qx3gks5uIDsMgaJpZM4T0IzV
.
--
-peter
@pvantilb I tried on a mac yesterday and it would not work without the network alias on the host machine. Once I enabled the alias, it all worked.
Bear with me, there are many steps you need to get right. It's easy to fail setting up xdebug ;-)
Please report back which steps already work for you and we'll go from there.
You get the devilbox status page when you call 10.254.254.254 because you have aliased that IP to 127.0.0.1 on the host. So that works as expected!
Calling curl on 10.254.254.254 from the php container also gives you the devilbox page because it's linked to the localhost loopback interface. So that also works as expected.
This means you've successfully set up the loopback alias. Good job! :+1:
The key here is understanding the xdebug config settings. I normally have a working setup when using remote connect back. Xdebug will figure out the remote host to connect back to from the http request sent by the browser on the host machine. In the case of Docker on Mac, this does not seem to work. The reason for this is that docker on Mac still is not entirely native, but running through an very thin virtual machine. I think.
Xdebug will try to connect to port 9000 on 10.254.254.254. So you can try to curl that port when trying to verify that phpstorm is listening there. Don't know if that will work. You'll need to learn how to speak the dbg protocoll, which is xml messages I believe.
One of the best articles on setting up xdebug at the moment: https://enrise.com/2018/02/debugging-php-with-xdebug/
xdebug.remote_connect_back = Off
xdebug.remote_enable = On
xdebug.remote_port = 9000
xdebug.remote_host = 10.254.254.254
xdebug.remote_log=/var/log/php/xdebug.log
If you have done this, you should be all set. Once you've restarted the php container, you can inspect the logfile:
# From the devilbox root folder:
./shell.sh
# From inside the php container:
tail -f /var/log/php/xdebug.log
Now you can see exactly what is going on.
Create a test site and verify that it works. Note that te site will run on port 80 by default on the host machine. You don't need any special ports like 8080 unless you have adjusted the default configuration files for devilbox. You should be all set when going to http://127.0.0.1 gives you the devilbox page.
In your case, you report working devilbox sites on port 8080, great. You test site should be available on port 8080 too.
./data/www/test/htdocs/index.php.<?php
$blah = 'Ohai';
$lala = $blah;
echo $blah;
phpinfo();
127.0.0.1 test.loc.Configure the browser and your IDE.
@Tuurlijk Thanks so much! i guess i jumped the gun assuming that the curl meant it wasn't working.
Once i adjusted xdebug.ini with the alias, phpstorm was able to receive xdebug connections and step throught breakpoints. Thanks for the detailed steps, everything is working now!
@Tuurlijk just to clarify this for the documentation.
When using xdebug.remote_connect_back = On without a remote host, do I still need the alias in lo0?
@cytopia On a Mac that remote_connect_back will not work. That is the option that tells xdebug to sort out the host on its own. And it seems to fail at that for some reason. So remote_connect_back will not work on Mac. You need to create the lo alias and specify the alias ip in xdebug.remote_host. Good work @pvantilb ! ;-)
@pvantilb next time read the solution to the end ^^ @Tuurlijk Ty for clarifying the end steps more than I did :)
@jmcbee @longelas @Tuurlijk @pvantilb
Documentation already available here:
https://devilbox.readthedocs.io/en/restructure-documentation/intermediate/configure-php-xdebug.html
Generalized Xdebug documentation now available: https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug.html
@cytopia I can also not ping host.docker.internal or any of the other names on my mac. I removed the network parts and all services except php from docker-compose and after that host.docker.internal could be resolved. So I guess it has something to do with the devilbox network configuration. I am not really familiar with the topic, but maybe you could add host.docker.internal to the internal docker DNS? Otherwise should host.docker.internal not be removed from the docs and explained why this is no option with devilbox?
@cytopia I just realized that it is already included in the docs (ping, if not working -> host alias address approach). I am still wondering why it would work for some, but not for others.
One more thing: It took me a long time to realize that the xdebug.ini examples in the docs include # for comments and I had to replace them with ; to make it work.
Apart from that, I have to say that devilbox is one of the best projects I came across on GitHub. Amazing work!
One more thing: It took me a long time to realize that the xdebug.ini examples in the docs include # for comments and I had to replace them with ; to make it work.
Awesome catch, I will update this: https://github.com/cytopia/devilbox/pull/421
Apart from that, I have to say that devilbox is one of the best projects I came across on GitHub. Amazing work!
Thanks. And this will probably also become better over time, once people find more edge-cases that can be fixed
What happens when you ping
host.docker.internalfrom inside the PHP container?Edit: did you read: https://devilbox.readthedocs.io/en/latest/tutorials/enable-xdebug.html
Alternative hostnames:
* docker.for.mac.host.internal * docker.for.mac.localhostPlease try to ping all of them and see which ones resolve
that link doesn't work, but I see this one does
@jmcbee @longelas @Tuurlijk @pvantilb @cycle337 @tobx
Xdebug documentation has been completely rewritten:
https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug.html