docker中安装zlib
root@506a8f5db441:/usr/src# apt-get install -y zlib1g-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
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.11.dfsg-1+deb10u2) but 1:1.2.11.dfsg-2+deb11u2 is to be installed
E: Unable to correct problems, you have held broken packages.
报错:
zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-1+deb10u2) but 1:1.2.11.dfsg-2+deb11u2 is to be installed
简单介绍一下当时的情况,我需要在docker php8.2.3的一个容器中安装dg扩展,gd扩展需要zlib,所以我就安装zlib结果报错。
解决:
先安装‘zlib1g=1:1.2.11.dfsg-1+deb10u2’
root@506a8f5db441:/usr/src# apt-get install zlib1g=1:1.2.11.dfsg-1+deb10u2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be DOWNGRADED:
zlib1g
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 90.9 kB of archives.
After this operation, 3072 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/debian-security buster/updates/main amd64 zlib1g amd64 1:1.2.11.dfsg-1+deb10u2 [90.9 kB]
Fetched 90.9 kB in 1s (155 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
dpkg: warning: downgrading zlib1g:amd64 from 1:1.2.11.dfsg-2+deb11u2 to 1:1.2.11.dfsg-1+deb10u2
(Reading database ... 15099 files and directories currently installed.)
Preparing to unpack .../zlib1g_1%3a1.2.11.dfsg-1+deb10u2_amd64.deb ...
Unpacking zlib1g:amd64 (1:1.2.11.dfsg-1+deb10u2) over (1:1.2.11.dfsg-2+deb11u2) ...
Setting up zlib1g:amd64 (1:1.2.11.dfsg-1+deb10u2) ...
Processing triggers for libc-bin (2.31-13+deb11u5) ...
然后继续执行安装zlib的命令:
root@506a8f5db441:/usr/src# apt-get install -y zlib1g-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
zlib1g-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 210 kB of archives.
After this operation, 436 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/debian-security buster/updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-1+deb10u2 [210 kB]
Fetched 210 kB in 1s (218 kB/s)