Skip to content

Instantly share code, notes, and snippets.

@kzap
Created August 8, 2018 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzap/658d1dfe599aa4b3b3ca3e31339e18d2 to your computer and use it in GitHub Desktop.
Save kzap/658d1dfe599aa4b3b3ca3e31339e18d2 to your computer and use it in GitHub Desktop.
Connect to XDebug running inside your PHP Container by building an image with XDebug installed and running like this: ```shdocker-compose -f docker-compose.yml -f docker-compose.xdebug.yml up
DOCKER_HOST_IP=IP.OF.YOUR.HOST.MACHINE.FROM.INSIDE.DOCKER
FROM FROM php:7.0-apache
RUN pecl install xdebug
ARG HOST_IP
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo '[xdebug]'; \
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)"; \
echo 'xdebug.remote_enable=1'; \
echo 'xdebug.remote_autostart=1'; \
echo 'xdebug.remote_log="/tmp/xdebug.log"'; \
echo "xdebug.remote_host=$HOST_IP"; \
} > /usr/local/etc/php/conf.d/xdebug.ini
# docker-compose -f docker-compose.yml -f docker-compose.xdebug.yml up
version: '3.2'
services:
web:
image: your-container:xdebug
build:
context: .
dockerfile: Dockerfile.xdebug
args:
HOST_IP: "${DOCKER_HOST_IP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment