docker容器无法执行vim【已解决】

在Docker容器中尝试安装vim时遇到速度慢和404错误。首先尝试更换163的镜像源失败,然后使用阿里的镜像源也出现404。最终成功的方法是切换到阿里云的bullseye镜像源,更新apt源后成功安装vim。完整步骤包括备份源列表,修改为阿里云镜像源,更新源并安装vim,最后验证vim是否安装成功。
摘要由CSDN通过智能技术生成

在这里插入图片描述

解决问题直接看完整步骤目录

docker容器中执行vim失败

bash: ll: command not found
bash: vim: command not found
bash: vi: command not found
安装vim依旧报错
在这里插入图片描述

我的版本 cat /etc/debian_version
11.2

安装文件

# 正常步骤,但是第一步下载非常慢,需要更换一下地址
1:apt-get update
2apt-get install -y vim
没更换之前,速度非常的慢

在这里插入图片描述

【失败】这里我更换了163的但是报错
Ign:1 http://mirrors.163.com/debian jessie InRelease
Ign:2 http://mirrors.163.com/debian jessie-proposed-updates InRelease       
Ign:3 http://mirrors.163.com/debian jessie-updates InRelease                
Ign:4 http://mirrors.163.com/debian jessie-backports InRelease
Ign:5 http://mirrors.163.com/debian-security jessie/updates InRelease
Get:6 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg InRelease [116 kB]
Err:7 http://mirrors.163.com/debian jessie Release      
  404  Not Found [IP: 101.71.33.11 80]
Err:8 http://mirrors.163.com/debian jessie-proposed-updates Release
  404  Not Found [IP: 101.71.33.11 80]
Err:9 http://mirrors.163.com/debian jessie-updates Release
  404  Not Found [IP: 101.71.33.11 80]
Err:10 http://mirrors.163.com/debian jessie-backports Release
  404  Not Found [IP: 101.71.33.11 80]
Err:11 http://mirrors.163.com/debian-security jessie/updates Release
  404  Not Found [IP: 101.71.33.11 80]
Reading package lists... Done
E: The repository 'http://mirrors.163.com/debian jessie Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.163.com/debian jessie-proposed-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.163.com/debian jessie-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.163.com/debian jessie-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.163.com/debian-security jessie/updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

在这里插入图片描述

【失败】这里我更换了阿里的第一种报错
root@a7e7ebb2ecad:/var/lib/apt/lists# echo -e "deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib \ndeb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib \ndeb http://mirrors.aliyun.com/debian-security stretch/updates main \ndeb-src http://mirrors.aliyun.com/debian-security stretch/updates main \ndeb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib \ndeb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib \ndeb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib \ndeb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" > /etc/apt/sources.list
root@a7e7ebb2ecad:/var/lib/apt/lists# 
root@a7e7ebb2ecad:/var/lib/apt/lists# cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib 
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib 
deb http://mirrors.aliyun.com/debian-security stretch/updates main 
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main 
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib 
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib 
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib 
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
root@a7e7ebb2ecad:/var/lib/apt/lists# apt-get update
Ign:1 http://mirrors.aliyun.com/debian stretch InRelease
Ign:2 http://mirrors.aliyun.com/debian-security stretch/updates InRelease  
Ign:3 http://mirrors.aliyun.com/debian stretch-updates InRelease           
Ign:4 http://mirrors.aliyun.com/debian stretch-backports InRelease         
Get:5 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg InRelease [116 kB]
Err:6 http://mirrors.aliyun.com/debian stretch Release   
  404  Not Found [IP: 60.28.226.53 80]
Err:7 http://mirrors.aliyun.com/debian-security stretch/updates Release
  404  Not Found [IP: 60.28.226.53 80]
Err:8 http://mirrors.aliyun.com/debian stretch-updates Release
  404  Not Found [IP: 60.28.226.53 80]
Err:9 http://mirrors.aliyun.com/debian stretch-backports Release
  404  Not Found [IP: 60.28.226.53 80]
Reading package lists... Done                            
E: The repository 'http://mirrors.aliyun.com/debian stretch Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/debian-security stretch/updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/debian stretch-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/debian stretch-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

在这里插入图片描述

【成功】::::这里我更换了阿里的第二种成功
#Aliyun Apt Source 阿里云镜像源
echo "deb http://mirrors.aliyun.com/debian/ bullseye main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main contrib" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main contrib" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main contrib" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian/ bullseye-proposed-updates main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-proposed-updates main contrib" >> /etc/apt/sources.list
root@a7e7ebb2ecad:/# apt-get update
Get:1 http://mirrors.aliyun.com/debian bullseye InRelease [116 kB]
Get:2 http://mirrors.aliyun.com/debian bullseye-updates InRelease [44.1 kB]           
Get:3 http://mirrors.aliyun.com/debian bullseye-backports InRelease [49.0 kB]
Get:4 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg InRelease [116 kB]
Get:5 http://mirrors.aliyun.com/debian bullseye-proposed-updates InRelease [54.0 kB]
Get:6 http://mirrors.aliyun.com/debian bullseye/contrib Sources [43.2 kB]
Get:7 http://mirrors.aliyun.com/debian bullseye/main Sources [8,637 kB]        
Get:8 http://mirrors.aliyun.com/debian bullseye/main amd64 Packages [8,183 kB]
Get:9 http://mirrors.aliyun.com/debian bullseye/contrib amd64 Packages [50.6 kB]
Get:10 http://mirrors.aliyun.com/debian bullseye-updates/main Sources [4,812 B]
Get:11 http://mirrors.aliyun.com/debian bullseye-updates/main amd64 Packages [14.6 kB]
Get:12 http://mirrors.aliyun.com/debian bullseye-backports/main Sources [429 kB]
Get:13 http://mirrors.aliyun.com/debian bullseye-backports/contrib Sources [4,280 B]
Get:14 http://mirrors.aliyun.com/debian bullseye-backports/main amd64 Packages [419 kB]
Get:15 http://mirrors.aliyun.com/debian bullseye-backports/contrib amd64 Packages [5,692 B]
Get:16 http://mirrors.aliyun.com/debian bullseye-proposed-updates/main Sources [8,072 B]
Get:17 http://mirrors.aliyun.com/debian bullseye-proposed-updates/main amd64 Packages [29.3 kB]
Fetched 18.2 MB in 6s (2,999 kB/s)                                                                                                                                                              
Reading package lists... Done

在这里插入图片描述

完整步骤

1:备份配置
cp /etc/apt/sources.list /etc/apt/sources.list.bak
2:修改配置
# Aliyun Apt Source 阿里云镜像源
echo "deb http://mirrors.aliyun.com/debian/ bullseye main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main contrib" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main contrib" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main contrib" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian/ bullseye-proposed-updates main contrib" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-proposed-updates main contrib" >> /etc/apt/sources.list
3:检查配置
cat /etc/apt/sources.list

在这里插入图片描述

4:执行:apt-get update

在这里插入图片描述

5:执行:apt-get install -y vim

在这里插入图片描述

6:验证
vim /etc/hosts

在这里插入图片描述

参考:

https://blog.csdn.net/yimaoya/article/details/125345414
https://blog.csdn.net/peng2hui1314/article/details/113247648

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值