douyi1084 2019-02-04 12:50
浏览 322
已采纳

使用magento / bin设置在docker中耗尽的PHP内存大小:di:compile

I got this error in log file after run php bin/magento setup:di:compile or php bin/magento deploy:mode:set production in php:7.1-fpm image's container.

[2019-02-04 12:15:26] main.ERROR: /usr/local/bin/php -f /var/www/html/m230/bin/magento setup:di:compile 2>&1 Compilation was started. %message% 0/7 [>---------------------------] 0% < 1 sec 72.0 MiB%message% 0/7 [>---------------------------] 0% < 1 sec 72.0 MiBProxies code generation... 0/7 [>---------------------------] 0% < 1 sec 72.0 MiB Proxies code generation... 1/7 [====>-----------------------] 14% 1 sec 76.0 MiB Repositories code generation... 1/7 [====>-----------------------] 14% 1 sec 76.0 MiB Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes) in /var/www/html/m230/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php on line 81 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors. [] []

I tried to increase memory limit by running php -dmemory_limit=1G bin/magento setup:di:compile or even php -dmemory_limit=-1 bin/magento setup:di:compile

This error doesn't occur if I use php:7.1-apache image (I use the same source code and database, just change image)

This error occurs on both my laptop (running arch-linux) and desktop (running ubuntu). I know they are strong enough to run that command.

My Dockerfile I used:

FROM php:7.1-fpm

# Install necessary libraries for Magento2
RUN apt-get -y update \
    && apt-get install -y \
        libmcrypt-dev \
        libxslt-dev \
        zlib1g-dev \
        libpng-dev \
        libjpeg-dev \
        libfreetype6-dev \
        libjpeg62-turbo-dev
RUN docker-php-ext-install -j$(nproc) iconv
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install pdo_mysql mcrypt xsl intl zip bcmath -j$(nproc) gd soap

# Install xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
RUN echo "xdebug.remote_enable=on
\
xdebug.remote_autostart=off
\
xdebug.remote_host=10.5.0.1
\
xdebug.remote_port=9000
\
xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# Set memory_limit
RUN echo "php_admin_value[memory_limit] = 2G" >> /usr/local/etc/php-fpm.d/www.conf

# Install cron
#RUN apt-get install -y cron

# Remove apt cache
RUN rm -rf /var/lib/apt/lists/*

# Create non-root user
ARG USER_NAME
ARG UID
RUN useradd -m -U ${USER_NAME} -u ${UID} -p1 -s /bin/bash -G root -o

# Edit PS1 in basrc
RUN echo "PS1='${debian_chroot:+($debian_chroot)}\w\$ '" >> /home/${USER_NAME}/.bashrc

# Change www-data user to ${USER_NAME}
RUN sed -i -e "s/www-data/${USER_NAME}/" /usr/local/etc/php-fpm.d/www.conf
  • 写回答

2条回答 默认 最新

  • dstd2129 2019-02-05 08:20
    关注

    In docker-compose.yml

    php:
        container_name: php-server
        build: ./php/
        volumes:
          - ./..:/var/www
          - ./php/ini:/usr/local/etc/php // note that this line maps docker's /usr/local/etc/php
    

    At your php Dockerfile directory under ini/conf.d/ create a file named memory_limit.ini So your directory will be .../php/ini/conf.d/memory_limit.ini Inside memory_limit.ini

    memory_limit = -1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?