1、容器内没有 vim 命令
当我们通过命令进入容器
[root@VM-16-11-centos ~]# docker exec -it wordpress /bin/sh
# vim
/bin/sh: 1: vim: not found
2、更新软件源
echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list
这一步的目的就是把原始的 apt-get 包源信息替换成清华的源,因为使用原始的在国外下载软件包很慢,当然你也可以换成其他,有很多可以选择,163、阿里都是不错的选择。
3、更新
# apt-get update
Ign:1 http://mirrors.163.com/debian jessie InRelease
Get:2 http://mirrors.163.com/debian jessie-updates InRelease [16.3 kB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease [270 kB]
Get:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease [114 kB]
Get:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease [99.8 kB]
Get:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease [110 kB]
Get:7 http://mirrors.163.com/debian-security jessie/updates InRelease [44.9 kB]
Err:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Get:8 http://mirrors.163.com/debian jessie Release [77.3 kB]
Err:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Get:9 http://mirrors.163.com/debian jessie Release.gpg [1652 B]
Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Hit:10 http://security.debian.org/debian-security bullseye-security InRelease
Err:2 http://mirrors.163.com/debian jessie-updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7638D0442B90D010
Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Ign:9 http://mirrors.163.com/debian jessie Release.gpg
Hit:11 http://deb.debian.org/debian bullseye InRelease
Hit:12 http://deb.debian.org/debian bullseye-updates InRelease
Reading package lists…… Done
耐心等待,直到完毕
4、下载 VIM
# apt-get install vim
Reading package lists…… Done
Building dependency tree…… Done
Reading state information…… Done
vim is already the newest version (2:8.2.2434-3+deb11u1).
0 upgraded, 0 newly installed, 0 to remove and 46 not upgraded.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:10 and /etc/apt/sources.list:14
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:11 and /etc/apt/sources.list:15
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:12 and /etc/apt/sources.list:16
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:13 and /etc/apt/sources.list:17
等待下载完毕,就可以正常使用 vim 了。