为什么我不能在新的ubuntu:22.04中运行"apt update"?



我目前没有设法在一个新的ubuntu:22.04(代号jammy)内运行apt update

协议
$ docker --version
Docker version 20.10.2, build 2291f61
$ docker run --init --rm -it ubuntu:22.04
root@123456789:/# apt update
观察到

$ docker run --init --rm -it ubuntu:22.04
root@6444bf2cb8b4:/# apt update
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [90.7 kB]            
Get:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [90.7 kB] 
Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [90.7 kB]             
Get:5 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1792 kB]       
Get:7 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]           
Get:8 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]             
Fetched 20.2 MB in 1s (17.6 MB/s)                                                           
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
root@6444bf2cb8b4:/# 
预期

apt updateubuntu:20.04的基础图像上通过…

注意:与apt-get install相同的问题…

裁判:https://hub.docker.com/_/ubuntu

似乎这与Glibc >= 2.34使用系统调用clone3有关…

所以你需要Docker >= 20.10.9来修复它。

ref: https://github.com/moby/moby/pull/42681
ref: https://pascalroeleven.nl/2021/09/09/ubuntu-21-10-and-fedora-35-in-docker/

我遇到了同样的问题。这是我的战术解决方法。

For context…

我在一个Gitpod实例中工作。

$ docker --version
Docker version 20.10.12, build e91ed57
$ docker pull ubuntu:22.04
$ docker run --rm -it ubuntu:22.04 /bin/bash
root@2fcf92fb7c84:/# apt update
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [90.7 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [90.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [90.7 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1792 kB]
Fetched 20.2 MB in 2s (11.1 MB/s)
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code

尽管上面的错误信息,更新是足以安装nano。我忽略了nano安装结束时的误导性错误信息。

root@3958950e9c57:/# apt install nano
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
:
E: Problem executing scripts DPkg::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code

My fix…

我使用nano编辑/etc/apt/apt.conf.d/docker-clean,注释掉第二行(APT::...)。随后,我遇到了类似的错误信息,第1行(DPkg::...);所以,它也被注释掉了。

可能只是删除docker-clean一起;但是现在,我留下了一行。

'//'和'#'都可以用来注释掉行。

root@3958950e9c57:/# nano /etc/apt/apt.conf.d/docker-clean
.. nano session not shown ..
root@3958950e9c57:/# cat /etc/apt/apt.conf.d/docker-clean
# DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
# APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";

结果…

现在被注释掉的行导致的令人困惑的消息消失了。

root@beab61fbde20:/# apt update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

需要改进…

一个更好的解决方案是修复我注释掉的行。我找不到合适的编辑;所以,把这行注释掉。

我用sed代替nano

FROM ubuntu:22.04
USER root
RUN sed -i -e 's/^APT/# APT/' -e 's/^DPkg/# DPkg/' 
/etc/apt/apt.conf.d/docker-clean

然后,标记一个调整后的Ubuntu图像供本地使用。

docker build -t fixed-ubuntu:22.04 -f Dockerfile .

我将docker引擎升级到20.10.14版本,问题解决了。

我有一个docker 20.10.18(最新的时间写作)不能工作,20.10.14开始工作

相关内容

  • 没有找到相关文章

最新更新