I was looking for a solution in which I would not have to hard code the docker host ip-address. Follow these steps to set it up for your container.
Looking for a LAMP or development stack? I have created mine with these Xdebug settings.
Docker translates host.docker.internal
in the ip-address of the host machine.
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host=host.docker.internal
Change the pathMapping to your needs
{
"version": "0.2.0",
"configurations": [
{
"name": "XDebug Dev Stack",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceRoot}/www"
}
}
]
}