docker 容器中出现 bash: xx: command not found
一、服务器中输入命令
# 启动tomcat容器 别名tomcat1
docker run -d -P --name tomcat1 tomcat
#进行tomcat1容器
docker exec -it tomcat1 /bin/bash
二、输入命令
ip
ip addr
bash: ip: command not found
ping
ping xx.xx.xx.xx
bash: ping: command not found
三、解决过程
ip
安装工具 iproute2
# 我的服务器是centos的
yum install -y iproute2
# 如果出现yum:command not found
apt-get update
或
apt-get install yum
# 再次执行安装命令
yum install -y iproute2
# 如果 yum install -y iproute2 出现问题 执行下面这行命令
apt install -y iproute2
结果

ping
安装iputils-ping、net-tools
# 依次输入
apt-get update
apt install iputils-ping
apt install net-tools
结果

即使再小的帆也能远航

浙公网安备 33010602011771号