Xdebug没有在Docker上运行

时间:2018-01-07 08:59:07

标签: docker xdebug

我正在尝试在我的Docker构建上设置Xdebug,但它没有像我预期的那样工作。我在我的Dockerfile中添加了RUN docker-php-ext-enable xdebug,我添加了以下xdebug.ini并将其映射到/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

此外,当我尝试添加RUN pecl install xdebug时,我最终会收到错误:

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

另外,我验证了构建它后我的容器环境有一个适当的扩展(没有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

我还在Dockerfile添加了以下行:

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

然而,当我运行phpinfo()时,我看到xdebug唯一出现的是

the xdebug.ini loaded

我错过了什么?

1 个答案:

答案 0 :(得分:0)

我不知道这是否有帮助(我是一个血腥的初学者!!!)但我遇到了同样的问题。这是我的Dockerfile

FROM php:7.1-apache

MAINTAINER Marcel Lange <info@ask-sheldon.com>

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

只需从

切换
RUN pecl install xdebug

RUN pecl install xdebug-2.6.0

为我解决了这个问题。

希望能帮到你......