进入docker
容器中后,需要用 vi
或 vim
编辑文件,提示 bash: vim: command not found
root@97117511bb12:/etc/mysql# vim my.cnf
bash: vim: command not found
这是因为没有安装vim
,我们需要先安装,使用下面的命令:apt-get install vim
如果提示下面的信息:
root@97117511bb12:/etc/mysql# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vim
需要输入下面的命令: apt-get update
root@97117511bb12:/etc/mysql# apt-get update
Get:2 http://repo.mysql.com/apt/debian stretch InRelease [21.6 kB]
Get:1 http://security-cdn.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:5 http://repo.mysql.com/apt/debian stretch/mysql-5.7 amd64 Packages [5695 B]
Ign:3 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:4 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:7 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 Packages [501 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [27.4 kB]
Get:9 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
Get:10 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [7082 kB]
Fetched 7944 kB in 6s (1318 kB/s)
Reading package lists... Done
再输入:apt-get install vim
root@97117511bb12:/etc/mysql# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
vim-common vim-runtime xxd
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-common vim-runtime xxd
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 6734 kB of archives.
After this operation, 31.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]
出现上面提示,输入:y
即可
Do you want to continue? [Y/n] y
Get:1 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 xxd amd64 2:8.0.0197-4+deb9u3 [132 kB]
Get:2 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 vim-common all 2:8.0.0197-4+deb9u3 [159 kB]
Get:3 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 vim-runtime all 2:8.0.0197-4+deb9u3 [5409 kB]
Get:4 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 vim amd64 2:8.0.0197-4+deb9u3 [1034 kB]
Fetched 6734 kB in 5s (1278 kB/s)
等待安装完成即可