为什么我无法在新的 ubuntu:22.04 中运行 `apt update`?

Miz*_*zux 62 ubuntu docker

我目前无法apt update在新的ubuntu:22.04(代号jammy)内运行。

协议

$ docker --version
Docker version 20.10.2, build 2291f61

$ docker run --init --rm -it ubuntu:22.04
root@123456789:/# apt update
Run Code Online (Sandbox Code Playgroud)

观察到的

$ 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:/# 
Run Code Online (Sandbox Code Playgroud)

预期的

apt update就像在基本图像上一样传递ubuntu:20.04...

注意:同样的问题apt-get install...

参考: https: //hub.docker.com/_/ubuntu

Miz*_*zux 65

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

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

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

  • 在这里使用版本 20.10.22。必须重新安装 Docker(使用“apt get update”更新未检测到更新)。以下 https://docs.docker.com/engine/install/ubuntu/#install-docker-engine 有帮助。最后重新启动应该就可以了。 (3认同)

WMC*_*WMC 24

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

对于上下文...

我正在 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
Run Code Online (Sandbox Code Playgroud)

快速纳米安装...

尽管出现上述错误消息,但更新足以安装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
Run Code Online (Sandbox Code Playgroud)

我的修复...

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

将所有内容一起删除可能没问题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 "";
Run Code Online (Sandbox Code Playgroud)

结果 ...

现在注释掉的行所产生的令人困惑的消息已经消失了。

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
Run Code Online (Sandbox Code Playgroud)

需要改进...

更好的解决方案是修复我已注释掉的行。我无法找到正确的编辑;所以,只是将该行注释掉。

在 Docker 中...

我用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
Run Code Online (Sandbox Code Playgroud)

然后,标记调整后的 Ubuntu 映像以供本地使用。

docker build -t fixed-ubuntu:22.04 -f Dockerfile .
Run Code Online (Sandbox Code Playgroud)


adi*_*yap 6

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