Free AI Opportunity Audit

XDebug inside Docker and DevContainer

Shyam Verma
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
        }
    ]
}
Shyam Verma

Shyam Verma

Full Stack Developer & Founder

Shyam Verma is a seasoned full stack developer and the founder of Ready Bytes Software Labs. With over 13 years of experience in software development, he specializes in building scalable web applications using modern technologies like React, Next.js, Node.js, and cloud platforms. His passion for technology extends beyond coding—he's committed to sharing knowledge through blog posts, mentoring junior developers, and contributing to open-source projects.