bash:/ bin / ping:在rhel 7.1 docker映像上不允许运行

[root@e732ba272c77 chef-repo]# ping www.google.com bash: /bin/ping: Operation not permitted 

尝试给/ bin / ping执行权限,但不能正常工作

 [root@e732ba272c77 chef-repo]# setcap cap_net_raw+ep /bin/ping [root@e732ba272c77 chef-repo]# ping www.google.com PING www.google.com (173.194.121.50) 56(84) bytes of data. 64 bytes from iad23s26-in-f18.1e100.net (173.194.121.50): icmp_seq=1 ttl=49 time=69.1 ms 64 bytes from iad23s26-in-f18.1e100.net (173.194.121.50): icmp_seq=2 ttl=49 time=68.7 ms 

您应该启动具有CAP_NET_ADMIN权限的docker容器,因为ping命令需要这个权限。

 docker run --cap-add net_raw --cap-add net_admin <other options> <container name> 

您可以参考以下链接获取更多信息: 如何在RHEL 7.1中启用ping