计算机网络/计算机科学与应用/系统/运维/开发

Docker 安装Vim

一、问题

在Docker中  vim无法直接使用


二、解决

首先更换Docker  镜像源  /etc/apt/sources.list

cat > /etc/apt/sources.list << EOF
 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
EOF


更新apt-get update 


如果更新时出现如下错误:

You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: apt-transport-https : Depends: libcurl3-gnutls (>= 7.16.2) but it is not going to be installed vim : Depends: vim-common (= 2:8.1.2269-1ubuntu5.29) but it is not going to be installed Depends: vim-runtime (= 2:8.1.2269-1ubuntu5.29) but it is not going to be installed Depends: libc6 (>= 2.29) but 2.24-11+deb9u3 is to be installed Depends: libcanberra0 (>= 0.2) but it is not going to be installed Depends: libgpm2 (>= 1.20.7) but it is not going to be installed Depends: libpython3.8 (>= 3.8.2) but it is not going to be installed Depends: libtinfo6 (>= 6) but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

执行修复命令:

apt --fix-broken install

检查并安装依赖包

apt-get install libcurl3-gnutls

如果遇到冲突文件,使用

dpkg -i --force-overwrite 强制覆盖冲突文件

最后再此更新

apt update

重新安装vim

apt-get install vim


操作步骤命令:

image.png

你努力了什么,也就成就了什么,与其羡慕别人,不如蜕变自己。

评论

^