Docker for Mac/Windowsで動作しているPHPアプリを、VS Codeからデバッグする方法です。
Docker for Mac/Windowsで起動したコンテナでは、host.docker.internal
というDNS名で、ホストのIPアドレスを引くことができるようになっています。
Xdebug の設定のxdebug.remote_host
に、この値を指定することで、コンテナ内のPHPとデバッガが通信できるようになります。
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_enable = 1
xdebug.remote_host = "host.docker.internal"
xdebug.remote_port = 9000
仮想環境でのPHPデバッグについて、詳しくは、Vagrant(+Docker) 上のPHPアプリをデバッグ実行するをご覧ください。