Ping不会安装在Docker容器中

时间:2019-05-19 19:08:04

标签: docker

我拉了Apache httpd image并跑了一个容器。但是,一次,我在容器中,ping不起作用,并且看到错误:“ bash:ping:命令未找到”。甚至无法ping 127.0.0.1。 Ping在容器外部工作。

cat /etc/resolv.conf在容器的内部和外部显示相同的名称服务器。我重新启动了Docker服务,但是,它也不能解决问题。

docker pull httpd
docker run -d --name testweb httpd
docker exec -it testweb /bin/bash
ping google.com

root@fb1ce4bccc11:/usr/local/apache2# ping google.com

bash: ping: command not found

我尝试安装Ping,但程序包管理器找不到它:

root@fb1ce4bccc11:/usr/local/apache2# yum -y install iputils-20160308-10.el7.x86_64
bash: yum: command not found

1 个答案:

答案 0 :(得分:1)

我找到了类似的帖子:Docker - Ubuntu - bash: ping: command not found

我的第一选择将是运行:

apt-get update
apt-get install iputils-ping