在 docker 容器中没有安装 vim 编辑器,需要使用 apt 命令安装,在更新 apt 软件包时遇到了一些坑,便记录下来。
遇到的坑主要是使用 apt 安装 vim 时,使用镜像为 163 的,总是报 ‘E: Sub-process /usr/bin/dpkg returned an error code (1)’ 错误,后来重新换了个阿里云的源解决了问题。
cd /etc/apt 里面有个 sources.list,执行下面代码使用阿里云镜像源。
echo "" > sources.list; \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse" >> sources.list; \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> sources.list; \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> sources.list; \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse" >> sources.list; \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> sources.list; \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse" >> sources.list; \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> sources.list; \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> sources.list; \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse" >> sources.list; \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> sources.list
如果出现了 The following signatures couldn’t be verified because the public key is not available,则按照下面代码执行
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 此处为错误信息的字符串
之后执行 apt-get update、apt-get install vim 都成功。
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 1216271933@qq.com