无法在 Docker 容器中检索最新版本的 Debian 软件包

Cannot retrieve latest version of Debian package inside Docker container

在 docker 容器中(从 node:9 图像创建)我正在尝试使用 apt-get 安装 stress-ng 包。但是,出于某种原因,每次我尝试安装时都会检索到旧版本的软件包。为了安装包,我使用命令:

root@7e7a683bf288:/usr/src/app# apt-get update
root@7e7a683bf288:/usr/src/app# apt-get install stress-ng

我得到以下版本:

root@7e7a683bf288:/usr/src/app# stress-ng --version
stress-ng, version 0.01.32

不过,如果可能的话,我想获得最新版本,0.09.42-1 (https://packages.ubuntu.com/cosmic/stress-ng)。我已经尝试过类似问题的一些解决方案,但无法使其正常工作。

附加信息:

root@7e7a683bf288:/usr/src/app# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

root@7e7a683bf288:/usr/src/app# cat /etc/apt/sources.list
deb http://deb.debian.org/debian jessie main
deb http://security.debian.org/debian-security jessie/updates main
deb http://deb.debian.org/debian jessie-updates main

root@7e7a683bf288:/usr/src/app# add-apt-repository 
bash: add-apt-repository: command not found

您必须将不稳定的存储库添加到您的 sources.list。当我这样做时,我仍然无法安装 stress-ng,正如它所说:

root@096865e3637f:/# apt-get install stress-ng
Reading package lists... Done
Building dependency tree       
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:
 libc6-dev : Breaks: binutils (< 2.26) but 2.25-5+deb8u1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

所以在安装之前我不得不删除 binutils

也许这是您的选择。

完整的 Dockerfile 如下所示:

FROM node:9
RUN echo "deb http://http.us.debian.org/debian unstable main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://http.us.debian.org/debian unstable main non-free contrib" >> /etc/apt/sources.list && \
apt-get remove binutils -y && \
apt-get update && \
apt-get install stress-ng -y
CMD stress-ng --version

stress-ng --version:

stress-ng, version 0.09.50

因此,它不是 0.09.42,而是最新的(不稳定的)版本 - 按照要求。