PhpStorm 2016.2 Help



Make sure that the following prerequisites are met:

Overview of Docker support

The Docker integration plugin adds the following to PhpStorm:

  • Docker configurations. These are named sets of settings for accessing the Docker Remote API.
  • Docker Deployment run/debug configurations. They let you download and build Docker images, and create and start Docker containers. Application debugging is supported only for PHP.
  • Docker tool window that lets you manage your Docker images and containers.
  • Docker Registry configurations that represent your Docker image repository user accounts.

Working with Docker: Process overview

  1. Install Docker and start the Docker daemon (on Windows and OS X - along with the Docker VM in which it runs). For corresponding instructions, see Get Started with Docker.
  2. Create a Docker configuration. You can do that:
    • Separately, in the Settings / Preferences dialog: Ctrl+Alt+S add | Docker.
    • When creating a Docker Deployment run configuration: Run | Edit Configurations | add | Docker Deployment, etc.
  3. Create a Docker Deployment run configuration.
  4. Execute the run configuration.
  5. Use the Docker Tool Window to manage your Docker images, containers and deployed applications.

PhpStorm and Docker integration configuration

At this point you have Docker and Docker Integration plugin for PhpStorm installed, so we can start with integration configuration.

Launching default Docker machine and getting necessary parameters

  1. Open the Docker Quickstart Terminal application. Docker will launch a default VM providing output in the console:
  2. In the Docker console, run the console command docker-machine env default. Thus you will get all the necessary parameters - you'll need them later for PhpStorm configuration (such as DOCKER_HOST and DOCKER_CERT_PATH):

Configuring PhpStorm to work with Docker

  1. In the Settings / Preferences dialog, open the Docker page under Build, Execution, Deployment, and click add to create a Docker configuration:
  2. In the Docker - Docker page, provide the following information:
  3. Apply the changes and close the Settings / Preferences dialog.

Creating a Docker Deployment run/debug configuration

Having set up Docker, create the run/debug configuration.

First, in the Deployment tab, specify the following:

  • Name. Here it is Start Docker.
  • Server. Here Docker server is selected from the drop-down list.
  • Deployment method. Here Dockerfile is selected.
  • Image tag. Here it is mysite.
  • Container name. Here it is Docker_Xdebug.

Next, in the Container tab, specify the necessary parameters.
At this point we are interested in exposing 80 port of the container to be available from our local machine, so we should configure a port binding for that:

Container port: 80, Protocol: tcp, Host IP: empty, Host port: 8080


Apply changes and close the Docker Deployment run/debug configuration dialog.

Working with Docker in PhpStorm

Running Docker from PhpStorm

As all the tools are installed, and the integration is configured, the recently created Start Docker Run/Debug Configuration can be launched:


The Application Servers Tool Window opens, updating you on the provisioning status and the current state of all your Docker containers:


As soon as the process is completed and our Docker_Xdebug container status turns green, one can check how it works in the browser. You should be able to open it by the URL similar to ( is an IP address of the default Docker machine, we've looked into where to get this parameter before). If you can't see the index.php execution results in the browser (that contains phpinfo(); in our case), make sure that you have specified the correct IP address and port bindings on the previous steps. In our example, everything is running fine on the port we've expected the app to be:


Managing Docker containers and other Docker-related actions in PhpStorm

From the Application Servers Tool Window, it’s easy to inspect containers and view running processes. PhpStorm also enables you to search through the logs, start and stop containers, and perform basic container management like creating and deleting containers. Each deployment in Docker is assigned a unique container ID - these are initially temporary containers, although they can be committed and saved for further distribution. On the Docker Hub registry, there are many such images available for you to try.


Images in Docker are read-only - once committed, any changes to a container’s state will become part of a new image. When you have a stable build on one instance of Docker (on your development machine, staging server, or a cloud), reproducing the exact same build is as simple as (1) committing the Docker container, (2) pushing it to a registry (public or private), then (3) pulling the same image to another instance of Docker, running - wherever.


Debugging PHP web application running in the Docker container

Assuming that you already run the Docker container now (and everything worked well on the previous steps), you should now able to open your PHP web application in the browser by http://host:port URL ( in our case). The major difficulty in getting Xdebug (or Zend Debugger) working with PhpStorm and Docker integration is the correct configuration of the Docker container.

In our case we're using a Dockerfile (we've already shown this config earlier and provided links to download it) to configure the container, including Xdebug-specific parameters, such as:

#Set up debugger RUN echo "zend_extension=/usr/lib/php5/20131226/" >> /etc/php5/apache2/php.ini RUN echo "xdebug.remote_enable=1" >> /etc/php5/apache2/php.ini #Please provide your host (local machine IP) instead of RUN echo "xdebug.remote_host=" >> /etc/php5/apache2/php.ini

In the example above we're modifying /etc/php5/apache2/php.ini providing a path to Xdebug extension, and some other Xdebug parameters (remote_enable and remote_host). Please note that xdebug.remote_host value should be replaced with your local machine IP address (where PhpStorm is running, in our case it is

Configuration for Zend Debugger is similar, please see a full tutorial on installing Xdebug and installing Zend Debugger (there's more information on required parameters and options).

Don't forget to re-run Start Docker Run/Debug Configuration so that all the changes are applied.

As soon as all the configs are in place, the debugging process can be triggered following this tutorial from step 2 (start Listening for PHP Debug Connections, set a breakpoint in the source code, start a debug session in the browser, reload the current page, debug).


See Also

Last modified: 2 September 2016