一,问题描述
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
{
"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 文件替换成下面下载路径。
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
版权声明:本文为qq_41169544原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。