旧版Ubuntu Docker镜像 apt 失败

在配置arm64v8/Ubuntu22.04镜像时,apt 失败,切换到国内源同样报错

究其原因是arm64v8/Ubuntu22.04是个精简镜像,没有ca证书, 需要安装ca-certificates, 但apt 不能用,死锁了。

根据网上/AI 提示, 下面三个方法均不起作用:

  1. 导入缺失的 GPG 公钥

> apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C

不起作用:" gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation"

  1. 手动下载并添加公钥

> gpg --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C

> gpg --export 871920D1991BC93C | tee /etc/apt/trusted.gpg.d/ubuntu-ports.gpg > /dev/null

不起作用:"gpg: command not found"

  1. 修复密钥文件的权限

>chmod 644 /etc/apt/trusted.gpg.d/*.gpg

不安全的解决方法

方法1. 所有apt update 增加参数 --allow-insecure-repositories --allow-unauthenticated

apt install增加参数 --allow-unauthenticated

> apt update --allow-insecure-repositories --allow-unauthenticated
> apt install --allow-unauthenticated xxxx

方法2. 修改 /etc/apt/sources.list

deb 后面增加**trusted=yes**

deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse

deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse

deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse

deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse

但上面方法都是直接取消安全验证,所以是不安全的。

相关推荐
数据知道15 分钟前
主机入侵检测(HIDS):OSSEC / Wazuh 部署与规则编写
安全·网络安全·docker
FriendshipT20 分钟前
Ubuntu 20.04 下使用 Ollama 本地部署 AI 大模型
linux·人工智能·python·深度学习·ubuntu
bellus-43 分钟前
win11使用ubuntu 26.04
linux·运维·ubuntu
逐光老顽童1 小时前
第 5 章:搞懂 K8s Service:从 ClusterIP 到负载均衡
docker·云原生·容器
略略略咯咯1 小时前
centos更换镜像源
linux·运维·centos
j7~2 小时前
【Linux】二十七.线程篇四《Linux多线程编程:线程互斥(互斥量的底层到封装)、线程安全和冲入、死锁》---详解
linux·开发语言·c++·线程安全·死锁·线程互斥·重入
yunwei372 小时前
eBPF 入门实践教程第五十篇:使用 TCX Link 实现可组合的流量控制
linux·云原生·开源
2401_827501282 小时前
Linux系统移植
linux·arm开发·单片机
2601_965798473 小时前
Build a Consulting Site in 2026: Nifty Theme Practical Review
java·linux·数据库
加油码3 小时前
共享内存详解:原理、系统调用与高性能进程间通信
linux·c语言·c++