docker php安装gd扩展_求助: PHP 安装 gd 库相关扩展遇到的问题(docker)

在尝试使用Dockerfile构建包含PHP7.1-fpm的镜像并安装GD库时,遇到了依赖包zlib1g-dev和libpng-dev的安装问题。错误提示表明存在无法解决的依赖冲突。尝试指定zlib1g-dev版本未成功,导致安装gd扩展失败。该问题在php7.0-fpm镜像中同样发生,其他扩展安装正常。
摘要由CSDN通过智能技术生成

当前所使用的用于构建镜像的 Dockerfile

FROM php:7.1-fpm

MAINTAINER Lestat Lee

#更新 apt-get 源 使用 163 的源,同时备份现有 sources.list

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \

echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list && \

echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \

echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \

echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list

RUN apt-get update \

&& apt-get install -y \

git \

zlib1g-dev \

libjpeg-dev \

libpng-dev \

&& curl -sS https://getcomposer.org/installer \

| php -- --install-dir=/usr/local/bin --filename=composer \

&& composer config -g repo.packagist composer https://packagist.phpcomposer.com \

&& composer global require hirak/prestissimo

#安装 gd 库

RUN docker-php-ext-install -j$(nproc) iconv

#&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \

#&& docker-php-ext-install -j$(nproc) gd

#安装 redis 扩展

RUN pecl install redis-4.0.1 \

&& pecl install xdebug-2.6.0 \

&& docker-php-ext-enable redis xdebug

EXPOSE 9000

问题描述

如果直接在上述 Dockerfile 目录执行docker build .,则会出现和下面一样的错误提示(下面的错误提示是我在没有安装 gd 扩展以及相关依赖的情况下构建镜像后进入到镜像内执行安装命令的提示),php7.1-fpm 默认系统是Debian GNU/Linux 9

[email protected]:/var/www/html# apt-get install -y zlib1g-dev libpng-dev && docker-php-ext-install gd

Reading package lists... Done

Building dependency tree

Reading state information... Done

Note, selecting 'libpng12-dev' instead of 'libpng-dev'

Some packages could not be installed. This may mean that you have

requested an impossible situation or if you are using the unstable

distribution that some required packages have not yet been created

or been moved out of Incoming.

The following information may help to resolve the situation:

The following packages have unmet dependencies:

zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2+b1) but 1:1.2.8.dfsg-5 is to be installed

E: Unable to correct problems, you have held broken packages.

在 google 上也找了很久,都说指定zlib1g的版本后可以解决这个问题,但是我在指定zlib1g版本后依然出现以下的提示

[email protected]:/var/www/html# apt-get install -y zlib1g-dev=1:1.2.8.dfsg-2+b1 libpng-dev && docker-php-ext-install gd

Reading package lists... Done

Building dependency tree

Reading state information... Done

Note, selecting 'libpng12-dev' instead of 'libpng-dev'

Some packages could not be installed. This may mean that you have

requested an impossible situation or if you are using the unstable

distribution that some required packages have not yet been created

or been moved out of Incoming.

The following information may help to resolve the situation:

The following packages have unmet dependencies:

zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2+b1) but 1:1.2.8.dfsg-5 is to be installed

E: Unable to correct problems, you have held broken packages.

我在 php7.0-fpm 镜像的 gd 库安装过程中也遇到同样的问题

除此之外其他扩展安装都很顺利,想请教一下各位这可能是什么原因造成的呢?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值