skip to Main Content

I am trying to get ImageMagick and it’s PHP extension working on a docker image

Docker Image:

FROM laravelphp/vapor:php81

RUN apk add imagemagick imagemagick-dev
RUN pecl install imagick
RUN docker-php-ext-enable imagick

COPY . /var/task

Running these commands gives the following error

  Step 1/5 : FROM laravelphp/vapor:php81                                                           
  php81: Pulling from laravelphp/vapor                                                             
  Digest: sha256:571d520c322df43e1a48ac28e1ff3ad88bf53a35d23837affd35f72fcdb35abd                  
  Status: Image is up to date for laravelphp/vapor:php81                                           
   ---> 46ebf272fe20                                                                               
  Step 2/5 : RUN apk add imagemagick imagemagick-dev                                               
   ---> Using cache                                                                                
   ---> 375e8ed62ce3                                                                               
  Step 3/5 : RUN pecl install imagick                                                              
   ---> Running in bc31590649b8 
                                                                   
  No releases available for package "pecl.php.net/imagick"                                         
  install failed   

What can I change to make pecl install imagick ?

2

Answers


  1. Chosen as BEST ANSWER

    In my case got it working with the following Dockerfile:

    FROM laravelphp/vapor:php81
    
    RUN apk add imagemagick imagemagick-dev php81-pecl-imagick 
    && pecl install imagick 
    && docker-php-ext-enable imagick
    
    COPY . /var/task
    

  2. I can share with you my working dockerfile:

    FROM laravelphp/vapor:php81
    
    RUN apk add --no-cache ${PHPIZE_DEPS} imagemagick
    
    RUN pecl install -o -f imagick
        &&  docker-php-ext-enable imagick
    
    RUN apk del --no-cache ${PHPIZE_DEPS}
    
    RUN php -i
    
    COPY . /var/task
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search