docker容器安装vi命令

1.今天进入docker容器中

docker exec -it 9d6c75e28991 /bin/bash

2.发现vim无法使用

root@9d6c75e28991:/etc/nginx# vi nginx.conf
bash: vi: command not found

3. 然后:

root@9d6c75e28991:/# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vim

4.接着:

root@9d6c75e28991:/# apt-get update
0% [Connecting to deb.debian.org] [Connecting to security.debian.org]
0% [Connecting to deb.debian.org] [Connecting to security.debian.org]
0% [Connecting to deb.debian.org] [Connecting to security.debian.org]y
Err:1 http://deb.debian.org/debian buster InRelease
Temporary failure resolving 'deb.debian.org'
Err:2 http://security.debian.org/debian-security buster/updates InRelease
Temporary failure resolving 'security.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease
Temporary failure resolving 'deb.debian.org'
Reading package lists... Done
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

5.紧接着:

[root@localhost /]# ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:89ff:fe6d:2f16 prefixlen 64 scopeid 0x20<link>
ether 02:42:89:6d:2f:16 txqueuelen 0 (Ethernet)
RX packets 5915 bytes 259507 (253.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6047 bytes 12957370 (12.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.189.128 netmask 255.255.255.0 broadcast 192.168.189.255
inet6 fe80::ea0f:2c57:24fd:9f2 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b7:5e:f2 txqueuelen 1000 (Ethernet)
RX packets 290327 bytes 352439515 (336.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 53010 bytes 8570953 (8.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 8 bytes 704 (704.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 704 (704.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth13b1ac3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::b008:e0ff:fe08:6b9e prefixlen 64 scopeid 0x20<link>
ether b2:08:e0:08:6b:9e txqueuelen 0 (Ethernet)
RX packets 5261 bytes 286483 (279.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5696 bytes 12917900 (12.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

6.继续:

[root@localhost /]# route add 172.17.0.0 mask 255.255.0.0 192.168.189.128
Usage: inet_route [-vF] del {-host|-net} Target[/prefix] [gw Gw] [metric M] [[dev] If]
inet_route [-vF] add {-host|-net} Target[/prefix] [gw Gw] [metric M]
[netmask N] [mss Mss] [window W] [irtt I]
[mod] [dyn] [reinstate] [[dev] If]
inet_route [-vF] add {-host|-net} Target[/prefix] [metric M] reject
inet_route [-FC] flush NOT supported

7. 接下来:

[root@localhost network-scripts]# route -v
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 100 0 0 ens33
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.189.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33

8. 重启docker:

systemctl restart docker

9. 重新进入:

docker exec -it 9d6c75e28991 /bin/bash

10. 更新: apt-get update 

root@9d6c75e28991:/# apt-get update
Get:1 http://deb.debian.org/debian buster InRelease [121 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://mirrors.aliyun.com/debian-security buster/updates InRelease [65.4 kB]
Get:4 http://mirrors.aliyun.com/debian-security buster/updates/main Sources [140 kB]
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [235 kB]
Get:6 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:7 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:8 http://deb.debian.org/debian buster-updates/main amd64 Packages [7868 B]
Fetched 8594 kB in 5min 43s (25.0 kB/s)
Reading package lists... Done
root@9d6c75e28991:/# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:

11. 安装vim

root@9d6c75e28991:/# 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

 

posted @ 2020-10-19 15:24  侠岚之弋痕夕  阅读(3443)  评论(0编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!