无法从ubuntu docker容器内ping谷歌

问题描述 投票:0回答:1

我是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"

并且可以从VM 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/

这可能是什么问题?

谢谢,

docker vagrant ubuntu-14.04 vagrantfile
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.