10

Docker Linux 没有vim怎么编辑文件

 3 years ago
source link: https://segmentfault.com/a/1190000039969652
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

相似提问:
Docker centos 没有vim怎么编辑文件?
Docker centos 没有vi怎么编辑文件?
Docker ubuntu 没有vim怎么编辑文件?
Docker ubuntu 没有vi怎么编辑文件?
下面的内容通通告诉你答案!!!!

为什么会有这个问题呢?

很简单,因为有中国有互联网长城,所以需要换源(你懂的)

没有vim,就要安装vim
怎么安装呢?
当然是执行下面语句

apt update
apt install vim

从Docker下载的镜像默认登录用户就是root,所以不需要加sudo,如果你不是这种情况,那就加上sudo

但是很慢啊,因为默认是ubuntu官方的源,速度感人

这个速度很迷,有的网络下可以有好几兆,那够用,有的网络下就只有几十KB,你懂的

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb 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 main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

这是一个标准的阿里云

这是ubuntu18的,你要是其他的版本或者发行版,就去找对应的软件源,不想像个沙子一样无脑复制

这么多内容肯定不行,累死人

我们只需要第一行

echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" > /etc/apt/sources.list

然后再执行

apt update
apt install vim

然后你就装上vim,装好vim之后再去

vim /etc/apt/sources.list

把完整的软件源都补上


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK