一,问题描述
docker 容器内运行vim 命令,报错 vim: command not found
二,问题原因
docker容器中没有安装vim ,安装vim 即可。
三,解决步骤
3.1 运行apt-get update 命令
3.1.1 如果运行 apt-get update 命令报错的话
Job for docker.service failed because the control
出现这个问题,大概率是DNS解析的问题,需要在宿主机指定下dns文章来源:https://www.toymoban.com/news/detail-517145.html
{
"dns": ["114.114.114.114","8.8.8.8"]
}
[root@localhost admin]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://ovulfay1.mirror.aliyuncs.com"],
"dns": ["114.114.114.114","8.8.8.8"]
}
3.1.2 apt-get update 命令过慢
在docker 对应的容器内运行apt-get update 命令,这个命令的作用是同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。运行过程中如果觉得下载速度过慢,可以将sources.list 文件替换成下面下载路径。文章来源地址https://www.toymoban.com/news/detail-517145.html
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
3.2 运行 apt-get install -y vim 命令即可
apt-get install -y vim
到了这里,关于docker vim: command not found的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!