How to install Imagick in PHP Docker?

The PHP docker image is build from the source and hence the usual apt-get install php-imagick doesn’t work at all. This might be frustrating for you as most of the solutions have a version attached to it. However, I found a way to always have it updated. Here is how –

Dockerfile for Imagick

This is how docker file should look like:

FROM php:7.3-apache
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick

Build Output

....

configuration option "php_ini" is not set to php.ini location
You should add "extension=imagick.so" to php.ini
Removing intermediate container 1c032fba6d45
 ---> 517795f672ac
Step 4/4 : RUN docker-php-ext-enable imagick
 ---> Running in 976ecd4a9627
Removing intermediate container 976ecd4a9627
 ---> 4b978dd49756
Successfully built 4b978dd49756

Git Repositor and Docker

How to install Imagick in PHP Docker?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top