mongodb - 带有 “Package ' mongodb的Docker构建失败,没有候选安装程序”

标签 mongodb docker docker-compose mongodb-query containers

直到今天早上,构建容器都是一个平稳的过程,现在我遇到了apt get -y mongodb的一些问题。

我有一个非常简单的Dockerfile,发布了相关代码,因为这是重现该问题所需要的。

FROM python:2.7

RUN apt-get update && \
    apt-get -y install \
        gpg \
        mongodb \


我研究了一些修复程序,但看起来有些过分,我是否应该更改基本镜像?我正在尝试了解此错误的原因以及如何将来对其进行验证。

注意,我忘了留下痕迹了。
Sending build context to Docker daemon  1.354GB
Step 1/7 : FROM python:2.7
2.7: Pulling from library/python
5ae19949497e: Pull complete
ed3d96a2798e: Pull complete
f12136850781: Pull complete
1a9ad5d5550b: Pull complete
6f18049a0455: Pull complete
900d7861659d: Pull complete
536c9e631831: Pull complete
cb522be31b83: Pull complete
d03d3d7b603d: Pull complete
Digest: sha256:ee76dd856d06bdd734e1c3c816b243c984586629708f0a3e32038f94a891a5d8
Status: Downloaded newer image for python:2.7
 ---> 3edf9092825f
Step 2/7 : RUN apt-get update &&     apt-get -y install         gpg         mongodb         curl
 ---> Running in 870a931ec60c
Get:1 http://security.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:2 http://deb.debian.org/debian buster InRelease [118 kB]
Get:3 http://security.debian.org/debian-security buster/updates/main amd64 Packages [11.9 kB]
Get:4 http://deb.debian.org/debian buster-updates InRelease [46.8 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7897 kB]
Fetched 8113 kB in 4s (1805 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package mongodb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'mongodb' has no installation candidate
The command '/bin/sh -c apt-get update &&     apt-get -y install         gpg         mongodb         curl' returned a non-zero code: 100

最佳答案

我猜您删除了旧的python:2.7图像并重建了dockerfile或只是换了另一台PC来进行了构建。如果使用新图像,则可以看到以下内容:

orange@orange:~$ docker images python:2.7
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
python              2.7                 3edf9092825f        8 hours ago         884MB

它显示了该图像是8个小时前创建的,因此与您几天前使用的图像相比,所使用的图像有很大不同。

this中,如果您搜索python:2.7,您现在可能会看到它与2.7.16-buster相同,就像您知道几天前发布的debian buster一样,请参见this:

2019-07-06: Initial release: 10.0 (press release)



因此,我想几天前python:2.7是基于debian stretch的,因此在新的debian版本中,删除了一些软件包,这会导致您失败。

最佳实践:

您会看到python dockerhub存储库中有Simple TagsShared Tags,请使用Simple Tags,它不会总是更改,请不要使用Shared Tags,后者以后可能会标记其他图像ID,对于您的情况,请使用python:2.7.16-stretch。实际上,此基础镜像是您过去使用的标记为python:2.7的镜像,而现在已标记为python:2.7的镜像不是您过去使用的镜像。

关于mongodb - 带有 “Package ' mongodb的Docker构建失败,没有候选安装程序”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57022983/

相关文章:

docker - 我正在从本地 Docker 迁移到远程 Docker,我可以发现守护进程的公共(public) IP 吗?

python - 在给定的 docker-compose 容器内执行 Python 脚本

javascript - 使用 'this' 引用与meteor.template.rendered

javascript - 什么是 MongoDB 的严格模式,使用它是个好主意吗?

ruby-on-rails-3 - MongoDB 无限滚动排序结果

windows - 启用 WSL2 的 Docker Desktop 无法在 Windows 10 中启动

mysql - ADD > LOAD .SQL 使用 Docker 自动构建和组合

java - 更新 mongodb 中数组数组内文档的字段

docker - 在 Docker 中以自定义用户身份运行 ASP.NET Core 应用程序

docker pull 给出无效的引用格式