Docker 构建 - mmap() 失败:[12] 无法分配内存(使用 Apple M1 芯片)

时间:2021-07-31 06:20:26

标签: docker docker-compose apple-m1 docker-build

我在尝试构建 docker 镜像时遇到以下错误(我使用的是 apple macbook pro M1 芯片,它已经有很多问题)。

错误日志-

 => ERROR [builder  7/15] RUN composer global require hirak/prestissimo --no-plugins --no-scripts --prefer-dist --no-progress --optimize-autoloader    4.8s
------                                                                                                                                                      
 > [builder  7/15] RUN composer global require hirak/prestissimo --no-plugins --no-scripts --prefer-dist --no-progress --optimize-autoloader:               
#14 0.487 Changed current directory to /root/.composer
#14 0.493 Do not run Composer as root/super user! See https://getcomposer.org/root for details
#14 1.516 Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
#14 4.793 
#14 4.793 mmap() failed: [12] Cannot allocate memory
#14 4.804 Segmentation fault
------
executor failed running [/bin/sh -c composer global require hirak/prestissimo --no-plugins --no-scripts --prefer-dist --no-progress --optimize-autoloader]: exit code: 139

Docker 文件 -

FROM nginx/unit:1.20.0-php7.3 as nginx-unit-php-base

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app/test
USER root

## Install package dependencies required at runtime.
RUN apt-get update \
    && apt-get -y install apt-utils \
    && apt-get -y install \
    php-apcu php-apcu-bc php-gd php-curl php-gettext \
    php-ldap php-msgpack php-soap php-wddx \
    php-zip php-imagick \
    php-bcmath php-mbstring php-mysql php-xml \
    php-redis php-memcached php-memcache php-intl \
    && apt-get clean

## Docker image with dependencies to build the arficacts, only used at build time.
FROM nginx-unit-php-base as builder

WORKDIR /app/test
## Install package depencencies required *only* at build time.
RUN apt-get update && apt-get -y install git composer procps make build-essential
## Add insecure access to GitHub private repositories with SSH
COPY .ssh /root/.ssh/
RUN touch /root/.ssh/known_hosts \
    && ssh-keyscan github.com >> /root/.ssh/known_hosts \
    && rm -rf .ssh

RUN composer global require hirak/prestissimo --no-plugins --no-scripts --prefer-dist --no-progress --optimize-autoloader

0 个答案:

没有答案