方案1
一般情况下可能会想到安装命令docker-php-ext-install gd
但是很有可能出现错误configure: error: png.h not found.
因为可能本身没有安装png等处理库
方案2
#更新安装依赖资源库
apt update
#安装基础库
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev
#设置配置文件
docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2
#安装扩展
docker-php-ext-install gd
#使扩展可用
docker-php-ext-enable gd
安装过程中如果出现了以下错误,可能是apt的源设置的不正确
可以在/etc/apt/source.list中设置中科大的源再尝试上面的操作deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
来源:CSDN
作者:kite.wang
链接:https://blog.csdn.net/qq_21891743/article/details/104734636