若是鏡像是基於ubuntu的,因此你可使用ubuntu的apt-get命令來安裝ping程序:docker
$apt-get install -y pingubuntu
apt-get 命令執行完畢以後,容器就會中止,但對容器的改動不會丟失。spa
在執行apt-get 命令的時候,要帶上-y參數。若是不指定-y參數的話,apt-get命令會進入交互模式,須要用戶輸入命令來進行確認,但在docker環境中是沒法響應這種交互的。blog
docker中安裝新程序命令:$docker run learn/tutorial apt-get install -y pingget