Use the following command to install imagick with Docker image php:7.1-fpm-alpine.

# imagick
RUN apk add --update --no-cache autoconf g++ imagemagick imagemagick-dev libtool make pcre-dev \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && apk del autoconf g++ libtool make pcre-dev

Caution: If you omit imagemagick package from the above line, builds will succeed. But it supports no image format. You can verify it with php -i command:

$ php -i|grep ImageMagick

Imagick compiled with ImageMagick version => ImageMagick 7.0.8-44 Q16 x86_64 2019-05-06 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.0.8-44 Q16 x86_64 2019-05-06 https://imagemagick.org
ImageMagick copyright => © 1999-2019 ImageMagick Studio LLC
ImageMagick release date => 2019-05-06
ImageMagick number of supported formats => o