Docker 没有ping 命令exec failed: unable to start container process: exec: “ping“

错误信息:unable to start container process: exec: “ping”: executable file not found in $PATH: unknown

进入容器执行

1、apt update

2、apt-get install -y iputils-ping
[root@liulihui ~]# docker exec -it tomcat02 /bin/bash
root@3df76acef167:/usr/local/tomcat# apt-get install -y iputils-ping
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 55 not upgraded.
Need to get 49.8 kB of archives.
After this operation, 116 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 iputils-ping amd64 3:20210202-1 [49.8 kB]
Fetched 49.8 kB in 16s (3194 B/s)                           
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package iputils-ping.
(Reading database ... 12909 files and directories currently installed.)
Preparing to unpack .../iputils-ping_3%3a20210202-1_amd64.deb ...
Unpacking iputils-ping (3:20210202-1) ...
Setting up iputils-ping (3:20210202-1) ...
root@3df76acef167:/usr/local/tomcat# 

测试:

[root@liulihui ~]# docker exec -it tomcat02 ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.143 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.047 ms
64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.110 ms
64 bytes from 172.17.0.2: icmp_seq=4 ttl=64 time=0.066 ms
^C
--- 172.17.0.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.047/0.091/0.143/0.037 ms

猜你喜欢

转载自blog.csdn.net/liulihui1988/article/details/128364436