問題(解決): bash: ping: command not found 以及同類型的問題

在使用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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容