美文网首页Ubuntu
问题(解决): bash: ping: command not

问题(解决): bash: ping: command not

作者: xrichardyan | 来源:发表于2017-08-04 23:35 被阅读0次

在使用Docker容器时,在容器内进行 ping localhost

$ docker run -it ubuntu
root@b4590299fe56:/# ping localhost
bash: ping: command not found

百度后有大佬建议用

apt-get install iputils-ping

可是......

root@b4590299fe56:/# apt-get install iputils-ping
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package iputils-ping

还是不行,正解是:

1)这时候需要敲:apt-get update,这个命令的作用是:同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。
2)等更新完毕以后再敲命令:apt-get install iputils-ping命令即可。

其他情况类比上面,例如:

bash: vim: command not found

都是先 apt-get update 再 install

相关文章

网友评论

    本文标题:问题(解决): bash: ping: command not

    本文链接:https://www.haomeiwen.com/subject/ojzblxtx.html