在Docker中,apt get install失败,并显示“;无法获取http://archive.ubuntu.com/ ... “404未找到”;错误。为什么?我们怎样才能渡过难关?
我的团队使用Docker(带有在Docker中,apt get install失败,并显示“;无法获取http://archive.ubuntu.com/ ... “404未找到”;错误。为什么?我们怎样才能渡过难关?,ubuntu,docker,Ubuntu,Docker,我的团队使用Docker(带有ubuntu:14.04base映像)进行本地开发,我们通常需要重建部分或全部映像。但是,即使在运行apt-get-y-update之后,下载带有apt-get-install的软件包时经常会失败。比如,今天我明白了 Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libxml2 amd64 2.9.1+dfsg1-3ubuntu4.7 404 Not Found [IP: 91.189.8
ubuntu:14.04
base映像)进行本地开发,我们通常需要重建部分或全部映像。但是,即使在运行apt-get-y-update
之后,下载带有apt-get-install
的软件包时经常会失败。比如,今天我明白了
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libxml2 amd64 2.9.1+dfsg1-3ubuntu4.7
404 Not Found [IP: 91.189.88.161 80]
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libxml2-dev amd64 2.9.1+dfsg1-3ubuntu4.7
404 Not Found [IP: 91.189.88.161 80]
Fetched 84.7 MB in 1min 6s (1281 kB/s)
Unable to correct missing packages.
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libx/libxml2/libxml2_2.9.1+dfsg1-3ubuntu4.7_amd64.deb 404 Not Found [IP: 91.189.88.161 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libx/libxml2/libxml2-dev_2.9.1+dfsg1-3ubuntu4.7_amd64.deb 404 Not Found [IP: 91.189.88.161 80]
E: Aborting install.
显然,特定软件包的特定版本已从存档中删除,并替换为名称稍有不同的补丁版本。例如,上面的错误正在查找libxml2_2.9.1+dfsg1-3ubuntu4.7_amd64.deb
,但服务器上的版本是libxml2_2.9.1+dfsg1-3ubuntu4.8_amd64.deb
通常这可以通过删除基本映像(docker rmi ubuntu:14.04
)并重建来解决;新下载的ubuntu映像具有正确的补丁号,并找到正确的存档文件。但即使这样也不总是可行——可能是因为Ubuntu依赖数据库的新的小升级和新的Ubuntu:14.04
映像部署到Docker Hub之间的延迟
我们已经尝试使用apt get
标志--修复缺失的
和--修复损坏的
,但这些标志也无法持续工作
还有其他想法吗
这是一个类似的问题,但被接受的答案是不可接受的,因为它不可能被自动化。我们的日常开发过程,包括自动构建和部署,都是使用Docker编写脚本的,每次特定归档文件丢失时,在Dockerfile中进行黑客攻击(然后在几小时或几天后删除黑客攻击)是不切实际的
作为对@prateek05的回应,这里是官方
ubuntu:14.04
docker图片中的/etc/apt/sources.list
:
root@72daa1942714:/# cat /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted
## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://archive.ubuntu.com/ubuntu/ trusty universe
deb http://archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates universe
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted
deb http://archive.ubuntu.com/ubuntu/ trusty-security universe
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security universe
# deb http://archive.ubuntu.com/ubuntu/ trusty-security multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ trusty-security multiverse
这个问题可能与ubuntu源代码有关 检查
/etc/apt/sources.list
如果您看到debhttp://archive.ubuntu.com/ubuntu 主宇宙受限多重宇宙
,这可能是潜在的问题
通过将其替换为deb来修复此问题http://archive.ubuntu.com/ubuntu/ 可靠的主宇宙受限多重宇宙
或者可能是镜子本身没有反应archive.ubuntu.com
Name: archive.ubuntu.com
Address: 91.189.88.152
Name: archive.ubuntu.com
Address: 91.189.88.161
Name: archive.ubuntu.com
Address: 91.189.88.149
Name: us.archive.ubuntu.com
Address: 91.189.91.23
Name: us.archive.ubuntu.com
Address: 91.189.91.26
用更可信的镜像替换archive.ubuntu.com,比如说us.archive.ubuntu.com
Name: archive.ubuntu.com
Address: 91.189.88.152
Name: archive.ubuntu.com
Address: 91.189.88.161
Name: archive.ubuntu.com
Address: 91.189.88.149
Name: us.archive.ubuntu.com
Address: 91.189.91.23
Name: us.archive.ubuntu.com
Address: 91.189.91.26
(由原始询问者编辑): 谢谢你,prateek05!我的Dockerfile现在开始:
FROM ubuntu:14.04
RUN sed -i'' 's/archive\.ubuntu\.com/us\.archive\.ubuntu\.com/' /etc/apt/sources.list
RUN apt-get -y update
而且它似乎在起作用。但由于这是一个零星的问题,只有时间会告诉我们……您已经声明Dockerfile包含
RUN apt get-y update
作为自己的RUN
指令。但是,由于以下原因,如果对docker文件的所有更改发生在文件的后面,当运行docker build
时,docker将重用上次执行run apt get-y update
时创建的中间映像,而不是再次运行该命令,因此,任何最近添加或编辑的apt get install
行都将使用旧数据,从而导致您观察到的错误
有两种方法可以解决此问题:
--no cache
选项传递给docker build
,强制每次生成映像时都运行Dockerfile中的每个语句apt get
命令组合在一个RUN
指令中:RUN apt get update&&apt get install foo bar…
。这样,每当编辑要安装的软件包列表时,docker build
将被迫重新执行整个RUN
指令,从而在安装之前重新运行apt get update
事实上,这家公司有。我建议您阅读。使用FTP源在100%的情况下都能正常工作
RUN echo \
'deb ftp://ftp.us.debian.org/debian/ jessie main\n \
deb ftp://ftp.us.debian.org/debian/ jessie-updates main\n \
deb http://security.debian.org jessie/updates main\n' \
> /etc/apt/sources.list
找到了一些有用的东西 所以我发现: 解决方案是创建一个包含内容的
pinning_文件
# Written by ubuntu-advantage-tools
Package: *
Pin: release o=UbuntuESM, n=trusty
Pin-Priority: never
然后加上
COPY pinning_file /etc/apt/preferences.d/ubuntu-esm-infra-trusty
在运行
sudo apt get-y更新之前,请先查看Dockerfile
。在我的情况下,问题是由父映像造成的,因为它没有正确清除apt缓存
我解决了这个问题,包括在第一次apt更新之前执行清理命令
RUN apt clean && \
rm -rf /var/lib/apt/lists/* && \
apt update && \
...
希望这有帮助我只有在为apt get添加了一些额外参数以处理http问题后才能修复此错误:
sudo apt-get \
-o Acquire::BrokenProxy="true" \
-o Acquire::http::No-Cache="true" \
-o Acquire::http::Pipeline-Depth="0" install \
ignition
在任何apt get install
之前,您是否总是执行apt get update
操作?是的,我们的基本dockerfile从运行apt get-y update
开始,这通常是在docker构建中还是在命令行上?在重建时,你使用什么来破坏docker build缓存?当这种情况发生时,我使用docker rmi ubuntu:14.04
,然后docker build
下载一个新的映像,并从那时开始无缓存地构建。你能发布一个示例Dockerfile
?排序可能会影响源。列表中我看到了许多我不了解的设置:--)trusty main restricted
,trusty universe
,trusty security main restricted
,trusty security universe
,但没有多宇宙
(注释掉的除外)。。。确切地说,我应该换什么?里面的东西看起来不错。这可能是由于镜像分辨率。你得到的镜子没有反应。要解决此问题,请直接指定镜像,例如将everyhare从archive.ubuntu.com更改为us.archive.ubuntu.comNOTE-您只需使用标志--no cache ONCE强制清除,然后可以删除该标志,以便为同一映像的后续docker构建。。。由于其他原因重复docker构建时方便/更快独立地--没有缓存
工作,但我已经运行了apt get update和apt get install…
,这还不够。我已经以任何频率传递了--没有缓存
参数?docker build-t d