I can not build my dockfile with php 8 laravel

Viewed 192

I run docker build but it error

when i build in FROM php:7.3-fpm-alpine it work but i want to use php 8 it not work this error i got

ERROR [ 4/10] RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl

executor failed running [/bin/sh -c docker-php-ext-install pdo_mysql mbstring zip exif pcntl]: exit code: 1

this my dockerfile

FROM php:8.0.7-fpm-alpine3.13 AS php
# FROM php:8.0.7-fpm-alpine not work
# FROM php:8.0.7-fpm-alpine3.13 not work
# FROM php:7.4-fpm not work
# FROM php:7.3-fpm  work

WORKDIR /var/www

RUN apk update && apk add \
    build-base \
    freetype-dev \
    libjpeg-turbo-dev \
    libpng-dev \
    libzip-dev \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl

RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd

# Install Extension
RUN apk add autoconf && pecl install -o -f redis \
&&  rm -rf /tmp/pear \
&&  docker-php-ext-enable redis && apk del autoconf

COPY ./config/php/local.ini /usr/local/etc/php/conf.d/local.ini

RUN addgroup -g 1000 -S www && \
    adduser -u 1000 -S www -G www

USER www

COPY --chown=www:www . /var/www


EXPOSE 9000

any one please advise me

1 Answers

I think these PHP extensions docker-php-ext-install pdo_mysql mbstring zip exif pcntl that you're trying to install are not available in this image FROM php:8.0.7-fpm-alpine if there is no specific reason for using the mentioned PHP image above. please try to change it to FROM php:8.1-fpm and try to re-build your Dockerfile.

if you tried these changes and you still getting the error that docker is not able to install zip extension you can use docker-php-extension-installer

add these lines to your Dockerfile

  1. Download php extension installer

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

  1. Give php extension installer a permission

RUN chmod +x /usr/local/bin/install-php-extensions

  1. Install php extensions via php extension installer

RUN install-php-extensions zip

Related