1、进入docker容器(ubuntu16.04官方镜像)
docker run -tid --name my_ubuntu 3edf
# -t 交互式操作 -i 表示终端 -d 表示后台运行 --name 指定容器名字 3edf为镜像id
docker exec -ti my_ubuntu /bin/bash
2、修改配置文件
- 先备份原有配置文件
cp /etc/apt/sources.list /etc/apt/sources.list.bak
rm /etc/apt/sources.list
或者
mv /etc/apt/sources.list /etc/apt/sources.list.bak
如果报错权限拒绝,命令前加sudo
- 修改镜像源配置(拉取的原始镜像是没有vim命令的)
echo "deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse" >> /etc/apt/sources.list
3.更新镜像源
执行命令apt-get update
,待全部更新后,即可使用 apt-get install vim
安装vim