Docker(一) 安装vim
1、安装Vim
在对docker容器中的文件进行修改时会提示bash: vim: command not found
的错误,这是由于docker中没有内置vim,需要我们手动安装。
通过apt-get install vim
命令进行安装vim,但是在进行安装过程中可能会出现如下的错误,
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vim
面对这种情况,可以使用apt-get update
命令对源进行更新,之后就可以正常安装。
在更新完成后重新使用apt-get install vim
命令即可完成vim的安装。
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgpm2 vim-common vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 vim vim-common vim-runtime
0 upgraded, 4 newly installed, 0 to remove and 130 not upgraded.
Need to get 6224 kB of archives.
After this operation, 28.9 MB of additional disk space will be used.
Do you want to continue? [Y/n]
2、常见问题
下载速度过慢
在进行下载过程中,由于apt默认为国外的源因此下载的速度速度会不稳定,有的时候会长达几十分钟,可以通过换源解决问题。
阿里云镜像开源社区镜像站
网易开源镜像站
清华大学开源镜像站
中科大开源镜像站
Debian全球镜像站
#1.进入容器
docker exec -it <容器名称/id> bash
#2.执行命令apt-get update 发现缓慢
#3.进入apt-get 配置目录
cd /ect/apt
#4.执行备份命令
cp sources.list sources.list.bak
#5.查看版本
cat /etc/os-release
###############################
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
###############################
#6.选择相应版本的源,同时执行echo下的4行命令,修改成国内镜像源
echo "">sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ jessie main contrib non-free">>sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-updates main contrib non-free">>sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security jessie/updates main contrib non-free">>sources.list
#7.查看文件 是否修改成功
cat sources.list
###############################
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ jessie main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-updates main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian-security jessie/updates main contrib non-free
###############################
#8.更新apt-get
apt-get update
#修改完成
apt-get install vim
#将备份完成的文件改回来,即可。
rm sources.list
mv sources.list.bak sources.list
报错:There is no public key available for the following key IDs
apt-get install debian-keyring debian-archive-keyring