我们在使用docker的时候,有时需要使用某些命令,比如使用vim命令或者使用systemctl的时候提示command not found。
1:现象,如下图:
2:原因饭呢西
容器内没有安装相关服务的命令
3:解决办法
命令公式:
apt-get update && apt-get install 需要的命令
比如这里凯哥(微信公众号 凯哥Java:kaigejava)这里需要更新yum命令。套用上面的公式
apt-get update && apt-get install yum
执行,会询问是继续。如下图;
输入Y。继续,然后会继续下载更新。
凯哥(微信公众号 凯哥Java:kaigejava)这里就记录一些常用的command not found命令在docker中怎么解决
(1)bash: ip: command not found
apt-get update && apt-get install -y iproute2
(2)bash: yum: command not found
apt-get update && apt-get install yum
(3)bash: ping: command not found
apt-get update && apt install iputils-ping
(4)bash: ifconfig: command not found
apt-get update && apt install net-tools
(5)bash: vi: command not found
apt-get update && apt-get install vim
(6)bash: route: command not found
apt-get update && apt-get install -y iproute2 && apt-get update && apt install net-tools
(7) bash: netstat: command not found
apt-get update && apt install net-tools
(8)bash: ps: command not found
apt-get update && apt-get install procps
(9)bash: top: command not found
apt-get update && apt-get install procps