skip to Main Content

I am getting the below error while trying to build a docker image (I am using apple macbook pro M1 chip, which already has a lot of issues).

The error log –

 => 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 file –

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

2

Answers


  1. I removed Docker Desktop from My Mac, and reinstalled the latest version (version 4.1.1 at the time), and the problem was solved.

    There was also a problem with a stuck update for me, so updating regularly also failed.

    Login or Signup to reply.
  2. For me usually setting DOCKER_DEFAULT_PLATFORM helps when I have docker build errors on my mac m1.
    Call this before building the docker image:

    export DOCKER_DEFAULT_PLATFORM=linux/amd64 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search