title: Setting up Xdebug with Docker Compose and WordPress image
body: <p>I am trying to set up Xdebug with docker-compose. I'm using PhpStorm IDE and the Docker image I'm using installs PHP 7.2. I'm trying to do this within the context of this WordPress image. Here is my current docker-compose.yml file:</p>
  
  <pre><code>    version: '3'
  
      services:
     db:
       image: mysql:5.7
       ports: 
         - "3306:3306"
       volumes:
         - db_data:/var/lib/mysql
       restart: always
       environment:
         MYSQL_ROOT_PASSWORD: somewordpress
         MYSQL_DATABASE: wordpress
         MYSQL_USER: wordpress
         MYSQL_PASSWORD: wordpress
  
     web-build-scripts:
       build: .
       depends_on:
         - db
       ports:
         - "8028:80"
         - "8029:8029"
  
       volumes:
         - ./themes/XXXXX:/var/www/html/wp-content/themes/XXXX
         - ./plugins/XXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
         - ./plugins/XXXXX:/var/www/html/wp-content/plugins/XXXXX
  
  
       restart: always
       environment:
         WORDPRESS_DB_HOST: db:3306
         WORDPRESS_DB_USER: wordpress
         WORDPRESS_DB_PASSWORD: wordpress
         VIRTUAL_HOST: leasepilot.local
  
  volumes:
      db_data:
  </code></pre>
  
  <p>Then my Dockerfile which I have tagged as web-build-scripts (and built of course) looks like this:</p>
  
  <pre><code>FROM wordpress:latest
  
  WORKDIR /var/www/html
  RUN pecl install xdebug-2.6.0 \
      &amp;&amp; docker-php-ext-enable xdebug \
      &amp;&amp; apt-get update \
      &amp;&amp; apt-get install nano \
      &amp;&amp; export TERM=xterm
  
  COPY Search-Replace-DB/ ./wp-content/Search-Replace-DB/
  COPY uploads/ ./wp-content/uploads/
  COPY ./docker-config/xdebug.ini ../../../usr/local/etc/php/conf.d/xdebug.ini
  </code></pre>
  
  <p>Where my xdebug.ini file that is within my docker-config directory locally looks like so:</p>
  
  <pre><code>zend_extension=xdebug.so
  xdebug.default_enable=1
  xdebug.remote_autostart=1
  xdebug.remote_connect_back=0
  xdebug.remote_port=9001
  xdebug.remote_enable=1
  xdebug.idekey=PHPSTR
  xdebug.remote_host = docker.for.mac.internal
  </code></pre>
  
  <p>Within PHPStorm I have set the debug settings like so:
  <a href="https://i.stack.imgur.com/k2Sd5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/k2Sd5.png" alt="enter image description here"></a>
  And I have set up the server mapping like so:
  <a href="https://i.stack.imgur.com/iaUB4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iaUB4.png" alt="enter image description here"></a></p>
  
  <p>I have also set the Debug Port to 9001 as I did in my xdebug.ini file:
  <a href="https://i.stack.imgur.com/KBCBd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KBCBd.png" alt="enter image description here"></a></p>
  
  <p>When I run the command php -ini | grep xdebug my output is as follows:</p>
  
  <pre><code>root@a96543427809:/var/www/html# php -ini | grep xdebug
  Cannot load Xdebug - it was already loaded
  /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
  /usr/local/etc/php/conf.d/xdebug.ini
  xdebug
  xdebug support =&gt; enabled
  xdebug.auto_trace =&gt; Off =&gt; Off
  xdebug.cli_color =&gt; 0 =&gt; 0
  xdebug.collect_assignments =&gt; Off =&gt; Off
  xdebug.collect_includes =&gt; On =&gt; On
  xdebug.collect_params =&gt; 0 =&gt; 0
  xdebug.collect_return =&gt; Off =&gt; Off
  xdebug.collect_vars =&gt; Off =&gt; Off
  xdebug.coverage_enable =&gt; On =&gt; On
  xdebug.default_enable =&gt; On =&gt; On
  xdebug.dump.COOKIE =&gt; no value =&gt; no value
  xdebug.dump.ENV =&gt; no value =&gt; no value
  xdebug.dump.FILES =&gt; no value =&gt; no value
  xdebug.dump.GET =&gt; no value =&gt; no value
  xdebug.dump.POST =&gt; no value =&gt; no value
  xdebug.dump.REQUEST =&gt; no value =&gt; no value
  xdebug.dump.SERVER =&gt; no value =&gt; no value
  xdebug.dump.SESSION =&gt; no value =&gt; no value
  xdebug.dump_globals =&gt; On =&gt; On
  xdebug.dump_once =&gt; On =&gt; On
  xdebug.dump_undefined =&gt; Off =&gt; Off
  xdebug.extended_info =&gt; On =&gt; On
  xdebug.file_link_format =&gt; no value =&gt; no value
  xdebug.filename_format =&gt; no value =&gt; no value
  xdebug.force_display_errors =&gt; Off =&gt; Off
  xdebug.force_error_reporting =&gt; 0 =&gt; 0
  xdebug.gc_stats_enable =&gt; Off =&gt; Off
  xdebug.gc_stats_output_dir =&gt; /tmp =&gt; /tmp
  xdebug.gc_stats_output_name =&gt; gcstats.%p =&gt; gcstats.%p
  xdebug.halt_level =&gt; 0 =&gt; 0
  xdebug.idekey =&gt; PHPSTR =&gt; PHPSTR
  xdebug.max_nesting_level =&gt; 256 =&gt; 256
  xdebug.max_stack_frames =&gt; -1 =&gt; -1
  xdebug.overload_var_dump =&gt; 2 =&gt; 2
  xdebug.profiler_aggregate =&gt; Off =&gt; Off
  xdebug.profiler_append =&gt; Off =&gt; Off
  xdebug.profiler_enable =&gt; Off =&gt; Off
  xdebug.profiler_enable_trigger =&gt; Off =&gt; Off
  xdebug.profiler_enable_trigger_value =&gt; no value =&gt; no value
  xdebug.profiler_output_dir =&gt; /tmp =&gt; /tmp
  xdebug.profiler_output_name =&gt; cachegrind.out.%p =&gt; cachegrind.out.%p
  xdebug.remote_addr_header =&gt; no value =&gt; no value
  xdebug.remote_autostart =&gt; On =&gt; On
  xdebug.remote_connect_back =&gt; Off =&gt; Off
  xdebug.remote_cookie_expire_time =&gt; 3600 =&gt; 3600
  xdebug.remote_enable =&gt; On =&gt; On
  xdebug.remote_handler =&gt; dbgp =&gt; dbgp
  xdebug.remote_host =&gt; docker.for.mac.internal =&gt; docker.for.mac.internal
  xdebug.remote_log =&gt; no value =&gt; no value
  xdebug.remote_mode =&gt; req =&gt; req
  xdebug.remote_port =&gt; 9001 =&gt; 9001
  xdebug.remote_timeout =&gt; 200 =&gt; 200
  xdebug.scream =&gt; Off =&gt; Off
  xdebug.show_error_trace =&gt; Off =&gt; Off
  xdebug.show_exception_trace =&gt; Off =&gt; Off
  xdebug.show_local_vars =&gt; Off =&gt; Off
  xdebug.show_mem_delta =&gt; Off =&gt; Off
  xdebug.trace_enable_trigger =&gt; Off =&gt; Off
  xdebug.trace_enable_trigger_value =&gt; no value =&gt; no value
  xdebug.trace_format =&gt; 0 =&gt; 0
  xdebug.trace_options =&gt; 0 =&gt; 0
  xdebug.trace_output_dir =&gt; /tmp =&gt; /tmp
  xdebug.trace_output_name =&gt; trace.%c =&gt; trace.%c
  xdebug.var_display_max_children =&gt; 128 =&gt; 128
  xdebug.var_display_max_data =&gt; 512 =&gt; 512
  xdebug.var_display_max_depth =&gt; 3 =&gt; 3
  </code></pre>
  
  <p>I've gone through several tutorials and haven't been able to figure this out. Anyone hav any insights that may help me?</p>