Docker没有vim如何安装,apt-get update报ERR404解决方案

问题描述

docker容器中安装vim报错
执行apt-get install vim后报错:

复制代码
E: Unable to locate package vim

更新安装源也报错
docker容器中执行apt-get update后报错:

复制代码
 #进入镜像命令
 #docker exec -it 镜像Id或镜像name /bin/bash
[root@tdengine ~]# docker exec -it xxxxx /bin/bash
 #更新安装源
root@b258a4f121b3:/# apt-get update
Ign http://security.debian.org jessie/updates InRelease
Ign http://deb.debian.org jessie InRelease
Ign http://security.debian.org jessie/updates Release.gpg
Ign http://deb.debian.org jessie-updates InRelease
Ign http://security.debian.org jessie/updates Release
Err http://security.debian.org jessie/updates/main amd64 Packages
Err http://security.debian.org jessie/updates/main amd64 Packages
Err http://security.debian.org jessie/updates/main amd64 Packages
Err http://security.debian.org jessie/updates/main amd64 Packages
Err http://security.debian.org jessie/updates/main amd64 Packages
  404  Not Found [IP: 151.101.194.132 80]
Ign http://deb.debian.org jessie-backports InRelease
Ign http://deb.debian.org jessie Release.gpg
Ign http://deb.debian.org jessie-updates Release.gpg
Ign http://deb.debian.org jessie-backports Release.gpg
Ign http://deb.debian.org jessie Release
Ign http://deb.debian.org jessie-updates Release
Ign http://deb.debian.org jessie-backports Release
Err http://deb.debian.org jessie/main amd64 Packages
  404  Not Found
Err http://deb.debian.org jessie-updates/main amd64 Packages
  404  Not Found
Err http://deb.debian.org jessie-backports/main amd64 Packages
  404  Not Found
W: Failed to fetch http://security.debian.org/dists/jessie/updates/main/binary-amd64/Packages  404  Not Found [IP: 151.101.194.132 80]
W: Failed to fetch http://deb.debian.org/debian/dists/jessie/main/binary-amd64/Packages  404  Not Found
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages  404  Not Found
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-backports/main/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

原因分析:

这个错误表明你使用的操作系统版本,即 Debian 8 (jessie) 已经停止支持并已归档,因此官方软件源已经关闭。

所以更新操作系统包列表时就会遇到 404 错误。

解决方案:

如果要继续使用这个操作系统版本,你需要使用归档的 Debian 镜像源来更新包列表。

你可以在 /etc/apt/sources.list 文件中添加以下内容,指定归档源地址(直接执行一下命令即可)

复制代码
#备份原文件
mv /etc/apt/sources.list /etc/apt/sources.list.bak
#添加源地址
echo "deb http://archive.debian.org/debian/ jessie main" >>/etc/apt/sources.list
echo "deb-src http://archive.debian.org/debian/ jessie main" >>/etc/apt/sources.list

重新安装

复制代码
root@b258a4f121b3:/# apt-get update
# 注意update执行完了之后可能还是会有报错,不过已经可以执行下面的安装语句了
root@b258a4f121b3:/# apt-get install -y vim
相关推荐
小和尚同志41 分钟前
29.4k!使用 1Panel 来管理你的服务器吧
linux·运维
帽儿山的枪手43 分钟前
为什么Linux需要3种NAT地址转换?一探究竟
linux·网络协议·安全
shadon1789 天前
回答 如何通过inode client的SSLVPN登录之后,访问需要通过域名才能打开的服务
linux
小米里的大麦9 天前
014 Linux 2.6内核进程调度队列(了解)
linux·运维·驱动开发
算法练习生9 天前
Linux文件元信息完全指南:权限、链接与时间属性
linux·运维·服务器
忘了ʷºᵇₐ9 天前
Linux系统能ping通ip但无法ping通域名的解决方法
linux·服务器·tcp/ip
浩浩测试一下9 天前
渗透测试指南(CS&&MSF):Windows 与 Linux 系统中的日志与文件痕迹清理
linux·运维·windows·安全·web安全·网络安全·系统安全
敏叔V5879 天前
大模型Text2SQL之在CentOS上使用yum安装与使用MySQL
linux·mysql·centos
小生云木9 天前
Linux离线编译安装nginx
linux·运维·nginx
API开发9 天前
苹果芯片macOS安装版Homebrew(亲测) ,一键安装node、python、vscode等,比绿色软件还干净、无污染
vscode·python·docker·nodejs·openssl·brew·homebrew