从运行 jessie 的 Debian docker 容器中我得到
vi blah
bash: vi: command not found
所以我很自然地使用我的安装命令
sudo apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vim
在寻找一些牵引力时,我遇到了这些带有各种输出的建议
cat /etc/apt/sources.list
deb http://deb.debian.org/debian jessie main
deb http://deb.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main
apt-get install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package software-properties-common
apt-get install python-software-properties
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-software-properties
apt-get install apt-file
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package apt-file
因为这个服务器是 mongo 镜像的 docker 容器,所以它故意是一个简单的 Debian 安装...安装 vi 只是为了在开发过程中玩玩
答案1
我找到了这个解决方案
apt-get update
apt-get install apt-file
apt-file update
apt-get install vim # now finally this will work !!!
这是上面的复制N粘贴版本
apt-get update && apt-get install apt-file -y && apt-file update && apt-get install vim -y
替代方法...如果您只需要创建一个新文件,请在没有可用编辑器时执行此操作
cat > myfile
(use terminal to copy/paste)
^D