4

I am trying to set up Xdebug on my Docker build but it's not working as I expect. I added RUN docker-php-ext-enable xdebug to my Dockerfile, I have added following xdebug.ini and mapped it to /usr/local/etc/php/conf.d/:

[xdebug]
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.profiler_enable=0
xdebug.max_nesting_level=700
xdebug.remote_autostart=off
xdebug.remote_host=192.168.0.1 # your ip
xdebug.remote_port=9001
xdebug.remote_connect_back=1

; with sane limits
html_errors = On
xdebug.default_enable=1
xdebug.var_display_max_depth = 5
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024

Also, when I try to add RUN pecl install xdebug I end up with error:

Step 26/31 : RUN pecl install xdebug
 ---> Running in e8ab055ec4a9
pecl/xdebug is already installed and is the same as the released version 2.5.5
install failed
ERROR: Service 'web' failed to build: The command '/bin/sh -c pecl install xdebug' returned a non-zero code: 1

Also, I verified there is a proper extension on my container environment once I build it (without this pecl install):

root@9763fbd22b39:/app# find /usr/local/lib/php/extensions/ -name xdebug.so
/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so

I also added following line to my Dockerfile:

RUN echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini

And yet, when I run phpinfo() the only occurrence of xdebug I see is

the xdebug.ini loaded

What am I missing?

1 Answer 1

5

I don't know if this helps (I'm a bloody beginner!!!) but I had the same issue. This was my Dockerfile

FROM php:7.1-apache

MAINTAINER Marcel Lange <[email protected]>

ENV XDEBUG_PORT 9000

RUN echo "######### LINUX:" $(/etc/issue)
RUN echo "######### PHP:"$(php --version)


# Install System Dependencies

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    apt-utils \
    software-properties-common \
    python-software-properties \
    libfreetype6-dev \
    libicu-dev \
    libssl-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng12-dev \
    libedit-dev \
    libedit2 \
    libxslt1-dev \
    libpcre3 \
    libpcre3-dev \
    apt-utils \
    redis-tools \
    mysql-client \
    git \
    vim \
    nano \
    wget \
    curl \
    lynx \
    psmisc \
    unzip \
    tar \
    cron \
    bash-completion \
    && apt-get clean

# Install Magento stack
RUN docker-php-ext-configure \
    gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/; \
    docker-php-ext-install \
    opcache \
    gd \
    bcmath \
    intl \
    mbstring \
    mcrypt \
    pdo_mysql \
    soap \
    xsl \
    zip

#install xdebug
RUN pecl install xdebug
RUN echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.iniOLD
RUN docker-php-ext-enable xdebug

And just switching from

RUN pecl install xdebug

to

RUN pecl install xdebug-2.6.0

resolved the issue for me.

Hope that helps you ...

Sign up to request clarification or add additional context in comments.

1 Comment

2021, using image: composer:latest install x-debug using pecl install xdebug-3.0.4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.