1、背景
最近在使用docker,通过镜像创建的容器里面,使用ping 命令报错:
root@c9fdfc1b40da:~# ping www.baidu.com
bash: ping: command not found
即在容器中没有ping工具。
2、安装命令
apt-get install inetutils-ping
示例如下:
root@c9fdfc1b40da:~# apt-get install inetutils-ping
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
netbase
The following NEW packages will be installed:
inetutils-ping netbase
0 upgraded, 2 newly installed, 0 to remove and 11 not upgraded.
Need to get 72.6 kB of archives.
After this operation, 389 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 netbase all 5.4 [12.7 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 inetutils-ping amd64 2:1.9.4-3ubuntu0.1 [59.9 kB]
Fetched 72.6 kB in 1s (55.0 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package netbase.
(Reading database ... 15445 files and directories currently installed.)
Preparing to unpack .../archives/netbase_5.4_all.deb ...
Unpacking netbase (5.4) ...
Selecting previously unselected package inetutils-ping.
Preparing to unpack .../inetutils-ping_2%3a1.9.4-3ubuntu0.1_amd64.deb ...
Unpacking inetutils-ping (2:1.9.4-3ubuntu0.1) ...
Setting up netbase (5.4) ...
Setting up inetutils-ping (2:1.9.4-3ubuntu0.1) ...
root@c9fdfc1b40da:~# ping www.baidu.com
PING www.a.shifen.com (180.101.49.12): 56 data bytes
64 bytes from 180.101.49.12: icmp_seq=0 ttl=50 time=13.000 ms
64 bytes from 180.101.49.12: icmp_seq=1 ttl=50 time=13.188 ms
64 bytes from 180.101.49.12: icmp_seq=2 ttl=50 time=10.175 ms
64 bytes from 180.101.49.12: icmp_seq=3 ttl=50 time=20.596 ms
64 bytes from 180.101.49.12: icmp_seq=4 ttl=50 time=9.954 ms
^C--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 9.954/13.383/20.596/3.854 ms
root@c9fdfc1b40da:~#