Debian GNU/Linux 系统 dockerfile 安装vim

105 阅读1分钟

安装docker镜像中总是会缺少vim的情况,现在根据镜像的操作系统信息来确定使用那种安装模式

1、查看系统信息

cat /etc/os-release

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

2、确定系统信息为 debian linux系统,同时版本在9版本

3、修改镜像源信息

1、备份原置

RUN mv -f /etc/apt/sources.list /etc/apt/sources.list.bak

2、通过echo修改源数据

RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" >/etc/apt/sources.list
RUN echo "deb-src http://archive.debian.org/debian/ stretch main contrib non-free" >>/etc/apt/sources.list
RUN echo "deb http://archive.debian.org/debian-security/ stretch/updates main contrib non-free" >>/etc/apt/sources.list
RUN echo "deb-src http://archive.debian.org/debian-security/ stretch/updates main contrib non-free" >>/etc/apt/sources.list
RUN echo "deb http://archive.debian.org/debian/ stretch-backports main contrib non-free" >>/etc/apt/sources.list

4、更新apt 并安装 vim

#更新工具
RUN  apt update	
#更新列表
RUN apt list --upgradable
# 安装vim
RUN apt install  -y vim --fix-missing
# 设置支持中文
RUN echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc
RUN echo "set termencoding=utf-8" >> /etc/vim/vimrc
RUN echo "set encoding=utf-8" >> /etc/vim/vimrc