Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

murilo's avatar
Level 10

Image intervention cant install extention in php:8.3-fpm-alpine

hello , I am using Image intervention v3 to resize image . it is showing me this error -

Imagick PHP extension must be installed to use this driver.

I tryed to install this extention, but I wass not succesfull .

I tryed to install this command in my php file -

FROM php:8.3-fpm-alpine
......
here other extentions ....
.....
RUN apt-get update; \
    apt-get install -y libmagickwand-dev; \
    pecl install imagick; \
    docker-php-ext-enable imagick;

but it is showing errors -

failed to solve: process "/bin/sh -c apk add --no-cache --virtual build-essentials     icu-dev icu-libs zlib-dev g++ make automake autoconf libzip-dev     libpng-dev libwebp-dev libjpeg-turbo-dev freetype-dev &&     docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp &&     docker-php-ext-install gd &&     docker-php-ext-install mysqli &&     docker-php-ext-install pdo_mysql &&     docker-php-ext-install intl &&     docker-php-ext-install bcmath &&     docker-php-ext-install opcache &&     docker-php-ext-install exif &&     docker-php-ext-install zip &&     apk del build-essentials && rm -rf /usr/src/php* RUN apt-get update;     apt-get install -y libmagickwand-dev;     pecl install imagick;     docker-php-ext-enable imagick;" did not complete successfully: exit code: 1

0 likes
5 replies
LaryAI's avatar
Level 58

It looks like you're trying to install the Imagick PHP extension in a Docker container based on the php:8.3-fpm-alpine image, but you're using apt-get commands which are intended for Debian-based distributions. Alpine Linux, which is the base of your image, uses apk as its package manager. Here's how you can correctly install the Imagick extension in your Dockerfile:

FROM php:8.3-fpm-alpine

# Install necessary packages for compiling Imagick
RUN apk add --update --no-cache autoconf g++ imagemagick imagemagick-dev libtool make pcre-dev

# Install Imagick extension
RUN pecl install imagick \
    && docker-php-ext-enable imagick

# Continue with your other extensions and customizations

This Dockerfile snippet does the following:

  1. Updates the package index and installs the necessary packages to compile the Imagick extension using Alpine's package manager apk.
  2. Installs the Imagick extension using pecl.
  3. Enables the Imagick extension in PHP using docker-php-ext-enable.

Make sure to place this snippet in the appropriate place in your Dockerfile, considering other PHP extensions and customizations you might have. This should resolve the installation issues you were facing with the Imagick extension.

murilo's avatar
Level 10

I tryed to use -

    docker-php-ext-enable imagick && \

but it gave the error

failed to solve: process "/bin/sh -c apk add --no-cache --virtual build-essentials     icu-dev icu-libs zlib-dev g++ make automake autoconf libzip-dev     libpng-dev libwebp-dev libjpeg-turbo-dev freetype-dev &&     docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp &&     docker-php-ext-install gd &&     docker-php-ext-install mysqli &&     docker-php-ext-install pdo_mysql &&     docker-php-ext-install intl &&     docker-php-ext-install bcmath &&     docker-php-ext-install opcache &&     docker-php-ext-install exif &&     docker-php-ext-install zip &&     docker-php-ext-enable imagick &&     apk del build-essentials && rm -rf /usr/src/php*" did not complete successfully: exit code: 1

Please or to participate in this conversation.