在使用docker时,有时候我们需要编辑配置文件,需要使用vim或者vi命令,发现:
root@64801a03b121:/etc/nginx/conf.d# vi default.conf bash: vi: command not foundroot@64801a03b121:/etc/nginx/conf.d# vim default.conf bash: vim: command not found
这是因为vim没有安装,使用如下命令安装:
root@64801a03b121:/etc/nginx/conf.d# apt-get install vimReading package lists... DoneBuilding dependency tree Reading state information... DoneE: Unable to locate package vim
此时需要更新:
root@64801a03b121:/etc/nginx/conf.d# apt-get updateGet:1 http://security-/debian-security buster/updates InRelease [39.1 kB] Get:2 http://cdn-fastly./debian buster InRelease [122 kB] Get:4 http://security-/debian-security buster/updates/main amd64 Packages [112 kB]Get:3 http://cdn-fastly./debian buster-updates InRelease [49.3 kB]Get:5 http://cdn-fastly./debian buster/main amd64 Packages [7899 kB]Get:6 http://cdn-fastly./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 vimReading package lists... DoneBuilding dependency tree Reading state information... DoneThe following additional packages will be installed:libgpm2 vim-common vim-runtime xxdSuggested packages:gpm ctags vim-doc vim-scriptsThe following NEW packages will be installed:libgpm2 vim vim-common vim-runtime xxd0 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] yGet:1 http://cdn-fastly./debian buster/main amd64 xxd amd64 2:8.1.0875-5 [140 kB]Get:2 http://cdn-fastly./debian buster/main amd64 vim-common all 2:8.1.0875-5 [195 kB]Get:3 http://cdn-fastly./debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB] Get:4 http://cdn-fastly./debian buster/main amd64 vim-runtime all 2:8.1.0875-5 [5775 kB]Get:5 http://cdn-fastly./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 installedSelecting 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 existProcessing triggers for libc-bin (2.28-10) ...
完成