Installing imagemagick in docker container

Thomas Horner picture Thomas Horner · Apr 11, 2016 · Viewed 23.2k times · Source

I'm trying to use ImageMagick on my Ubuntu 14.04 server for resizing an image before uploading to s3. I'm running everything inside of a docker container that's being created by Wercker. The problem is I've already installed it on the server, and installed it in the Wercker build for the docker container, yet my EasyImage (nodejs library handling the resizing) is saying

 ImageMagick Not Found
 EasyImage requires ImageMagick to work. Install it from http://www.imagemagick.org/script/binary-release.php.

This is the command I have in my Wercker file to install imagemagick

sudo apt-get update -y && sudo apt-get install -y imagemagick php5-imagick

I've also used

sudo apt-get update -y && sudo apt-get install -y imagemagick

, but neither seem to work. Am I missing something to get ImageMagick working inside of a docker container?

Answer

Rakesh Sadaka picture Rakesh Sadaka · Mar 22, 2018

You need to install imagick using pecl and extension to enable imagick in php. The following command worked for me:

RUN apt-get update && apt-get install -y \
    imagemagick libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
    && docker-php-ext-enable imagick