Dockerfile

FROM php:7-apache

# 启用国内软件源
COPY ./sources.list /etc/apt/

# 安装需要的类库
RUN apt-get update && apt-get install -y \
    libmagickwand-6.q16-dev --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# 安装需要的php扩展
RUN pecl install imagick-3.4.3 \
    && docker-php-ext-enable imagick

sources.list

deb http://mirrors.aliyun.com/debian stretch main
deb http://mirrors.aliyun.com/debian stretch-updates main
deb http://mirrors.aliyun.com/debian-security stretch/updates main

根据实际 os 版本修改源文件

参考