XDebug inside Docker and DevContainer

Make sure xdebug is installed inside the docker

# add xdebugger
RUN pecl install xdebug \
    && docker-php-ext-enable xdebug

The Xdebug config inside docker should have "client_host" set to "host.docker.internal"

xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes

At last the launch.json for VSCode open inside devcontainer should be like

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        }
    ]
}