Guide
Run and Debug a PHP Application in Docker Using PhpStorm
Configure PhpStorm’s Docker integration to launch a containerized PHP app, map ports, mount source code, and debug with Xdebug breakpoints.
Published by Tasadduq Burney
10 Feb 2026, 02:19 UTC
2 min72.8K views0

Desired outcome
Run a PHP application inside a Docker container from PhpStorm, expose it on a host port, and debug it with Xdebug breakpoints.
Prerequisites
- Docker Engine installed and running.
- PhpStorm 2023.2 or later with the Docker plugin enabled.
- A PHP project that contains a Dockerfile defining a web server (e.g., nginx + php‑fpm) and exposes the application port.
- The PhpStorm user has permission to access the Docker daemon (on Linux add the user to the
dockergroup or configure sudo).
Procedure
- Open
Settings → Build, Execution, Deployment → Docker. - Click the
+button, chooseDocker, keep the default Unix socket (/var/run/docker.sock) or specify a TCP address, clickApply. - Navigate to
Run → Edit Configurations, press+and selectDocker Run. - In the configuration form:
- Set
Container nameto a meaningful value, e.g.,my-php-app. - Select the
Dockerfilefrom your project. - Under
Port bindings, map container port80to a host port, for example8080(fieldHost Port). - Under
Volume bindings, add a bind mount:Host path= absolute path to your project source,Container path=/var/www/html. Use a.dockerignorefile to excludevendorandnode_modulesif they exist. - Click
OKto save the configuration.
Expected checks
- Start the configuration via the
Rundropdown or theServicestool window. - In the
Serviceswindow, locate the container; it should show a green icon and list the port mapping (0.0.0.0:8080->80/tcp). - Open a browser at
http://localhost:8080(replace8080with your host port) and verify the PHP application’s index page loads. - Enable Xdebug listening:
Settings → PHP → Debug, ensureCan accept external connectionsis on. - Set a breakpoint in a PHP file, click the
Debugbutton next to the configuration, make a request (e.g., refresh the browser), and confirm the debugger session appears in theDebugtool window and suspends at the breakpoint.
Recovery options
- If the container fails to start, open the
Docker logtab inside the run configuration to view error messages. - Correct Dockerfile syntax, resolve port conflicts (change host port), or adjust volume paths, then rerun.
- To revert, stop the container via the
Serviceswindow (right‑click →Stop). - Optionally delete the run configuration from
Run → Edit Configurations. - Run
docker system prune -fin a terminal to remove stopped containers and free space (only if you are sure no needed containers remain).
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.