

That way when you try to use you IDE, you will not see an error like Can't start listening for connections from 'xdebug': Port 9000 is busy. This is the first trick for Linux, do not expose the port, just use it. Note that I’m not exposing the 9000 port (the default xdebug port) in any of Docker settings. One web service that is an official Docker nginx image, the web server I will use in this example, finally, fpm, that will be based on our previous Dockerfile and where we will discuss variations in the next section. I’ve defined three services, data, a busybox with the only purpose of mount and map volumes that will be shared by the other services. Let’s break down the example below: version: '2' Now we will need a docker-compose.yml to orchestrate the whole setup. ini file instead of a bunch of bash command. I choose this way because I think is easier to maintain an. Note that I also copied “xdebug.ini” from etc folder, both, folder and file should exists in the same directory as Dockerfile, otherwise you will need to change the source path to the real location of your custom “xdebug.ini”.
Phpstorm xdebug docker install#
We need to create this file instead of use the official php:5.6-fpm image, because we need to run the pecl install command within the created container. etc/xdebug.ini /usr/local/etc/php/conf.d/ # here I'm copying the config file we will discuss in the next sectionĬOPY. RUN apt-get update & apt-get install -y \ So let’s start creating a custom Dockerfile that will look like this: FROM php:5.6-fpm To try out the container clone from github, My example will be based on a clean Erdiko project, so I already have the structure to test, umm debug, some code.

Here we will discuss the very basic settings to create a container. This step is pretty much the same for all alternatives and OS platforms. Well, I don’t have the answer for all this questions, but I will show some examples and tips various ways to setup xdebug inside your docker container and connect it with PHPStorm. Some questions came to my mind when I stumbled upon this situation: How do I setup the container? How can I expose xdebug outside of my containers? How can I integrate remote debugging with my IDE workflow?
Phpstorm xdebug docker how to#
Yeah, if you want to use a tool like xdebug (here is a great tutorial about how to install it Remote PHP Debugging with Xdebug) within Docker containers. Okay, it does not enough complicated so, now let’s add DevOps. There are several strategies we can use to manage debugging, from stopping execution after dump / print the content of the variable we want to inspect (I still with this more often that I’d like to admit) to more sophisticated tools or web-server modules. Debugging, an issue that all developers should live with.
