Docker---問題1:bash: vi: command not found/bash: vim: command not found

在使用docker時,有時候我們需要編輯配置文件,需要使用vim或者vi命令,發現:

root@64801a03b121:/etc/nginx/conf.d# vi default.conf 
bash: vi: command not found
root@64801a03b121:/etc/nginx/conf.d# vim default.conf 
bash: vim: command not found

這是因爲vim沒有安裝,使用如下命令安裝:

root@64801a03b121:/etc/nginx/conf.d# apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package vim

此時需要更新:

root@64801a03b121:/etc/nginx/conf.d# apt-get update
Get:1 http://security-cdn.debian.org/debian-security buster/updates InRelease [39.1 kB]            
Get:2 http://cdn-fastly.deb.debian.org/debian buster InRelease [122 kB]    
Get:4 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [112 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7899 kB]                                                                                                                                                 
Get:6 http://cdn-fastly.deb.debian.org/debian buster-updates/main amd64 Packages [5792 B]                                                                                                                                                     
Fetched 8226 kB in 5min 26s (25.2 kB/s)                                                                                                                                                                                                       
Reading package lists... Done

再次安裝:

root@64801a03b121:/etc/nginx/conf.d# apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libgpm2 vim-common vim-runtime xxd
Suggested packages:
  gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
  libgpm2 vim vim-common vim-runtime xxd
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 7425 kB of archives.
After this operation, 33.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cdn-fastly.deb.debian.org/debian buster/main amd64 xxd amd64 2:8.1.0875-5 [140 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian buster/main amd64 vim-common all 2:8.1.0875-5 [195 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB]                                                                                                                                              
Get:4 http://cdn-fastly.deb.debian.org/debian buster/main amd64 vim-runtime all 2:8.1.0875-5 [5775 kB]                                                                                                                                        
Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 vim amd64 2:8.1.0875-5 [1280 kB]                                                                                                                                              
Fetched 7425 kB in 5min 53s (21.1 kB/s)                                                                                                                                                                                                       
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package xxd.
(Reading database ... 7203 files and directories currently installed.)
Preparing to unpack .../xxd_2%3a8.1.0875-5_amd64.deb ...
Unpacking xxd (2:8.1.0875-5) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../vim-common_2%3a8.1.0875-5_all.deb ...
Unpacking vim-common (2:8.1.0875-5) ...
Selecting previously unselected package libgpm2:amd64.
Preparing to unpack .../libgpm2_1.20.7-5_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.7-5) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a8.1.0875-5_all.deb ...
Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.1.0875-5) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a8.1.0875-5_amd64.deb ...
Unpacking vim (2:8.1.0875-5) ...
Setting up libgpm2:amd64 (1.20.7-5) ...
Setting up xxd (2:8.1.0875-5) ...
Setting up vim-common (2:8.1.0875-5) ...
Setting up vim-runtime (2:8.1.0875-5) ...
Setting up vim (2:8.1.0875-5) ...
...
...
...
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group editor) doesn't exist
Processing triggers for libc-bin (2.28-10) ...

完成

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章