New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ddev uses host ip address for host.docker.internal, doesn't work with vscode language server #3781
Comments
Could you please show the output of This is Ubuntu 20.04? And not in WSL2, right? |
Yes, Ubuntu 22.04 (and was been reproducible on 20.04 too), here is my [
{
"Name": "bridge",
"Id": "0984523bdd2135dc1fdfa4a0f4e334fffee3656192217c008e2441257b3f30c3",
"Created": "2022-04-28T00:30:21.109906849+04:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
] |
ddev uses the gateway value Could you please gist the .ddev/.ddev-docker-compose-base.yaml on gist.github.com and link it here? The host.docker.internal is defined there. |
It puts it to
But the problem is that is the host's ip (not the internal container's ip), so xdebug listener, launched internally inside container, can't catch the connections. And here is my |
It looks to me like ddev is doing everything right. Can you please check this with a trivial new project, one of the quickstarts? |
Btw, the debug listener is on host, not in container. |
This problem is reproducible for me with a trivial new empty project.
|
I wish you had mentioned vscode server long ago (or maybe I missed it?). That's different from what anybody has ever talked about before in all these years :) You can use .ddev/php config to change the I imagine, assuming your vscode addon is listening on localhost inside the container. |
I've mentioned
And yeah, Bug glad to have this working out-of-the box by default, without manual actions, if it's possible... |
Thanks!
Note that the "normal" vscode experience/configuration is described in https://ddev.readthedocs.io/en/latest/users/step-debugging/#visual-studio-code-vscode-debugging-setup |
Your workaround doesn't work for me. I have to delete the line with host.docker.internal from the hosts file inside the ddev web container. Then xdebug works. But after every restart ddev set the entry again in the /etc/hosts file. For me it would help If ddev would not set the host.docker.internal entry:) |
@rfay you are right. I use PHPStorm on Windows and yes I've an other open issue but MurzNN meant I should take a look in this issue cause he could have a workaround which could help me too. But yeah, didn't read that he is using vs code server. Sorry. |
@rfay I've started describing briefly the benefits here https://murz.notion.site/VS-Code-IDE-inside-Docker-container-fe31affafff747cdac8382167f3a03d9 - will post it on my blog when finished. |
Thanks - Looking forward to it. Please do a PR to add to https://github.com/drud/awesome-ddev when you do the blog. Since this is completely different from every other usage (and depends on the IDE, not ddev's config) we'll have to figure out how config can be done in the future. |
Better late than never! 😜 Here it is: ddev/awesome-ddev#22 |
Thanks! |
With #4242 which just went in, you should be able to do this without workarounds now. You can use this latest version with |
Yeah, this works - thanks! |
Is there an existing issue for this?
Run a Diagnostic and Paste Link Here
Click to expand
$ ddev debug test Running bash [-c /tmp/test_ddev.sh] OS Information: Linux MURZ_COMP 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux User information: uid=1000(alexey_korepov) gid=1000(alexey_korepov) groups=1000(alexey_korepov),4(adm),24(cdrom),27(sudo),30(dip),44(video),46(plugdev),109(render),120(lpadmin),132(lxd),133(sambashare),997(docker) DDEV version: ITEM VALUE DDEV version v1.19.1 architecture amd64 db drud/ddev-dbserver-mariadb-10.3:v1.19.0 dba phpmyadmin:5 ddev-ssh-agent drud/ddev-ssh-agent:v1.19.0 docker 20.10.14 docker-compose v2.3.3 docker-platform MURZ_COMP mutagen 0.12.0 os linux router drud/ddev-router:v1.19.0 web drud/ddev-webserver:v1.19.0-1 ======= DDEV global info ========= Global configuration: instrumentation-opt-in=true omit-containers=[] mutagen-enabled=false nfs-mount-enabled=false router-bind-all-interfaces=false internet-detection-timeout-ms=750 disable-http2=false use-letsencrypt=false letsencrypt-email= table-style=default simple-formatting=false auto-restart-containers=false use-hardened-images=false fail-on-hook-fail=false required-docker-compose-version= use-docker-compose-from-path=false no-bind-mounts=false======= DOCKER info =========
docker location: -rwxr-xr-x 1 root root 61890504 Mar 24 05:45 /usr/bin/docker
======= Mutagen Info =========
======= Docker Info =========
Docker platform: MURZ_COMP
Using docker context: default (unix:///var/run/docker.sock)
docker-compose: v2.3.3
Using DOCKER_HOST=unix:///var/run/docker.sock
Docker version: 20.10.14
Able to run simple container that mounts a volume.
Able to use internet inside container.
Docker disk space:
Filesystem Size Used Available Use% Mounted on
overlay 105.2G 74.9G 24.9G 75% /
The ddev-ssh-agent container has been removed. When you start it again you will have to use 'ddev auth ssh' to provide key authentication again.
Existing docker containers:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Creating a new ddev project config in the current directory (/home/alexey_korepov/tmp/tryddevproject-28837)
Once completed, your configuration will be written to /home/alexey_korepov/tmp/tryddevproject-28837/.ddev/config.yaml
Found a php codebase at /home/alexey_korepov/tmp/tryddevproject-28837
Project type has no settings paths configured, so not creating settings file.
Configuration complete. You may now run 'ddev start'.
Network ddev_default created
Starting tryddevproject-28837...
Container ddev-ssh-agent Started
ssh-agent container is running: If you want to add authentication to the ssh-agent container, run 'ddev auth ssh' to enable your keys.
Pushed mkcert rootca certs to ddev-global-cache/mkcert
Network ddev-tryddevproject-28837_default Created
Container ddev-tryddevproject-28837-web Started
Container ddev-tryddevproject-28837-dba Started
Container ddev-tryddevproject-28837-db Started
Container ddev-router Started
Project type has no settings paths configured, so not creating settings file.
Project type has no settings paths configured, so not creating settings file.
Successfully started tryddevproject-28837
Project can be reached at https://tryddevproject-28837.ddev.site https://127.0.0.1:49161
curl --fail -I tryddevproject-28837.ddev.site
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Thu, 28 Apr 2022 06:42:22 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
'[' 0 -ne 0 ']'
set +x
Thanks for running the diagnostic. It was successful.
Please provide the output of this script in a new gist at gist.github.com
Running ddev launch in 5 seconds
Current Behavior
I've got the problem with connecting to XDebug within a ddev-web container. It enables well, but PHP script can't connect to debugger port.
Seems this is because the
host.docker.internal
hostname is attached to a wrong IP.But I've found a workaround how to fix this issue via manually editing
/etc/hosts
file, it's described in "Steps To Reproduce".Expected Behavior
PHP script should connect to debugger port successfully.
Steps To Reproduce
Create a new test environment via
ddev config --project-type drupal9
.Enable xdebug via
ddev xdebug enable
Attach VS Code to container, configure XDebug with default settings:
/var/www/html/index.php
with a simple script:Place a breakpoint on the line.
Launch the script from console and see that xdebug can't connect to the host:
/etc/hosts
file:See that the subnet for
172.17.0.1
ip is missing.host.docker.internal
to the172.21.0.2
ip via modifying the/etc/hosts
file like this:php ./index.php
- xdebug starts working well!Anything else?
No response
The text was updated successfully, but these errors were encountered: