我是docker和linux的新手,我正试图在docker容器中ping谷歌。我收到以下错误....
vagrant@vagrant-ubuntu-trusty-64:~$ docker run ubuntu ping google.com
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec: \"ping\":
executable file not found in $PATH": unknown.
如上所述,我在流浪汉上使用ubuntu/trusty64 box。
我在vagrantfile中启用了公共网络
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network"
可以从虚拟机ping谷歌
vagrant@vagrant-ubuntu-trusty-64:~$ ping google.com
PING google.com (216.58.204.46) 56(84) bytes of data.
64 bytes from lhr25s12-in-f14.1e100.net (216.58.204.46): icmp_seq=1 ttl=52 time=29.5 ms
64 bytes from lhr25s12-in-f14.1e100.net (216.58.204.46): icmp_seq=2 ttl=52 time=36.2 ms
64 bytes from lhr25s12-in-f14.1e100.net (216.58.204.46): icmp_seq=3 ttl=52 time=95.7 ms
但似乎不在docker容器内。
我尝试了这个解决方案,但没有帮助 - https://odino.org/cannot-connect-to-the-internet-from-your-docker-containers/
这可能是什么问题?
谢谢,
答案 0 :(得分:2)
错误消息告诉您" ping"命令不包含在ubuntu基本映像中。 Docker图像被剥离,您需要安装您想要在其中运行的任何应用程序。如果使用/ bin / bash运行容器,则可以使用以下命令在该容器中安装ping:
apt-get update && apt-get install iputils-ping
您可以在nicolaka/netshoot
中找到ping和许多其他网络工具,我喜欢它们用于网络故障排除:
docker run -it --rm nicolaka/netshoot ping www.google.com