docker 内安装vim 时错误解决

分类:Linux |

在docker内执行安装vim时, 会有以下报错:


进入 docker 命令行: docker exec -it xxx /bin/bash


~$ vi

bash: vi: command not found



~$ apt-get install vi

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)

E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?


~$ sudo apt-get install vi

bash: sudo: command not found


~$ apt-get update

Reading package lists... Done

E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)


~$ sudo apt-get update

bash: sudo: command not found



解决方法:

1. 使用以下方式登录到docker

docker exec -u root -it xxx /bin/bash


2. 登录到docker后,执行以下命令

apt-get update


3. 登录到docker后,执行以下命令

apt-get install vim