Integrating Docker with Xdebug and Sublime Text on PHP environment

I’m setting up a Docker development environment for my team. In this environment we want to integrate Xdebug with Docker to allow for debugging. It seems the easiest way to do this is to connect Sublime Text to the Docker instance and then install Xdebug ontop on Sublime Text. I found the following guide for integrating Sublime Text with Docker ( and this guide for integrating Xdebug with Sublime Text ( What I am wondering is if anyone has any experience setting up similar environments? Is there an easier way to do this? Does this seem like the correct way to debug PHP code inside Docker?

  • docker custom network connexion refused between
  • Beanstalk-Docker configuration issues for serving HTTP/HTTPS requests
  • Docker modify iptables of a single running container
  • Best practice for redirecting between docker containers
  • Docker for Windows cleanup
  • Do I want a container handling multiple requests?
  • Django model changes not reflected on Postgres Docker container
  • Docker : Cannot connect to the Docker daemon. Is the docker daemon running on this host?
  • Docker Swarm Linking
  • proxypass to phpmyadmin container but got error 502 and Connection refused
  • Make Rails app folder read-only?
  • Unable to modify files in container from docker
  • One Solution collect form web for “Integrating Docker with Xdebug and Sublime Text on PHP environment”

    This solution may also work for Sublime Text – For Visual Studio Code, I have just recently got this working. I found these remote_host and other Xdebug settings work for me on both Windows 10 Pro and OS X using the latest versions of Docker Community Edition.

    In the Xdebug extension configuration, I set these along with the Xdebug extension installation in the Dockerfile of the image package from docker hub that contains php. There is a link to a post at the bottom of this answer on how this was done in the Dockerfile and how the image was built and then added to the docker-compose file.

    1. The xdebug.remote_connect_back setting needs to be off: xdebug.remote_connect_back=0
    2. Autostart xdebug.remote_autostart=1 it just works.
    3. xdebug.remote_host= needs to be changed depending on Windows or OS X as follows:

    Windows 10 Professional running Docker Version 17.03.0-ce-win1, open a command prompt and enter ipconfig. The address is listed under DockerNAT. For example:

    Ethernet adapter vEthernet (DockerNAT):
        IPv4 Address. . . . . . . . . . . :

    OS X El Capitan running Docker Version 17.03.0-ce-mac2, create an alias of IP to your existing subnet mask.

    sudo ifconfig en0 alias

    Then use the IP for the xdebug.remote_host setting for your host as follows based on the examples above:

    1. Windows
    2. OS X:

    Note, if you run into a conflict in OS X, you can remove the alias like so.

    sudo ifconfig en0 -alias

    I use Visual Studio Code with the vscode-php-debug PHP Debug Adapter to Listen for Xdebug and step through my code. Note the following needs to be included in the project launch.json file in order for VS Code to map the remote server files to the local machine. This is from my project and its typical volume locations, your serverSourceRoot looks to be the same.

    "serverSourceRoot": "/var/www/html",
    "localSourceRoot": "${workspaceRoot}"

    The entire setup for docker-compose, nginx-proxy including how to build the image with Xdebug and more at Docker WordPress Dev Environment – Remote Debugging with Xdebug and VS Code

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.