docker出现问题:容器中bash: vi: command not found解决方案

本文介绍了在Docker容器中安装vim编辑器的方法。当在基础容器内进行文件编辑时,若遇到未安装vim的情况,可通过运行特定命令来解决。文章还解决了安装过程中可能遇到的源找不到的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

docker使用教程相关系列 目录


问题

我们在创建基础容器之后,进入容器,进行编辑配置文件的时候,需要使用vim或者vi命令,但是会出现:
在这里插入图片描述

这是因为vim没有安装。

解决方案

使用如下命令安装:

apt-get update
apt-get install vim

然后就可以了。


如果 这个时候 安装也还是会出现 异常

在这里插入图片描述

root@446d7cf1606c:/etc/mysql# apt-get update
Err:1 http://security.debian.org/debian-security buster/updates InRelease                           
  Temporary failure resolving 'security.debian.org'
Err:2 http://repo.mysql.com/apt/debian buster InRelease                                             
  Temporary failure resolving 'repo.mysql.com'
Err:3 http://deb.debian.org/debian buster InRelease                                                 
  Temporary failure resolving 'deb.debian.org'
0% [Connecting to deb.debian.org]
Err:4 http://deb.debian.org/debian buster-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists... Done    
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://repo.mysql.com/apt/debian/dists/buster/InRelease  Temporary failure resolving 'repo.mysql.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@446d7cf1606c:/etc/mysql# 

 

从 异常我们可以看出来,安装找不到源。

解决方法:

sudo systemctl restart docker

对没错,重启docker即可。目的是为了,让源…等等配置文件重新启动,然后再重新对接接口下载。

在这里插入图片描述
没问题了。

参考这个博主的解决方案:

https://pea328.blog.csdn.net/article/details/105010261

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值