OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ip": executable file not found in $PATH: unknown (Docker容器没有ip addr命令:exec ip addr 报错)
一、报错
1、报错信息1:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ip": executable file not found in $PATH: unknown
2、报错原因:
我们下载的某个镜像(例如tomcat镜像)是精简版的,利用这个镜像去打开一个容器的时候发现没有ip addr这个命令。
3、解决报错1的方法:安装工具 iproute2
# 进入容器内部(比如tomcat01容器)
docker exec -it --name tomcat01 -P tomcat:9.0 /bin/bash
apt install -y iproute2
注意:查看一下容器的系统版本信息:
cat /etc/os-release
★ Linux系统分为两种:
1.RedHat系列:Redhat、Centos、Fedora等
2.Debian系列:Debian、Ubuntu等
RedHat系列的包管理工具是yum
Debian系列的包管理工具是apt-get
● 查看系统版本命令:cat /etc/os-release
二、又报错:
1、报错信息2:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package iproute2
2、报错原因:
包管理工具apt的镜像是国外的导致,下载速度过慢导致的。
3、解决报错2的方法:更换apt 配置文件中的镜像
# 进入配置文件
cd /etc/apt
# 查看目录信息
ls
cat sources.list
# 备份
mkdir cat sources.list.backup
cp sources.list ./sources.list.backup
cd ../
# 以覆盖+追加的方式替换掉sources.list文件
echo 'deb https://mirrors.aliyun.com/debian bullseye main'>sources.list
echo 'deb https://mirrors.aliyun.com/debian-security bullseye-security main'>>sources.list
echo 'deb https://mirrors.aliyun.com/debian bullseye-updates main'>>sources.list
# 执行一下更新命令:
apt-get update -y
# 执行下载 iproute2命令:
apt install -y iproute2
三、问题解决,测试一下,在docker 容器内使用ip 命令
# 测试1:-it 与容器进行交换
docker exec -it --name tomcat01 -P tomcat:9.0 ip addr
# 测试2:先进入容器,然后测试ip命令
docker exec -it --name tomcat01 -P tomcat:9.0 /bin/bash
ip a
以下,是我,搜索本问题时,被误导产生的一些无效折腾
■ 被误导在centos7(我的宿主机)中安装 iproute2,实则是centos新版版(比如centso7/centos8早已内置网络工具iproute2)
■ 然后又为了解决Docker容器没有ip addr命令,在宿主机安装 epel-release,结果报错,没有找到这个包,是因为网上的解决方案,命令不全,没有先执行下载 epel-release安装包,就直接来个yum install,导致找不到包。
■ 同样,对于 iproute2,也是没有给出下载命令,却直接来个安装命令yum install iproute2,导致找不到包iproute2。
■ 最重要的是 centos新版本已经内置有了iproute2,没必要安装呀
■ 最最最重要的是跑题了,咱需要考虑的是命令ip是在docker容器执行失败,而在宿主机执行正常!解决起点应该回到容器内安装网络工具 iproute2。因为下载的镜像是精简版的,默认不自带网络工具iproute2。
● Docker容器没有ip addr命令:exec ip addr 报错:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ip": executable file not found in $PATH: unknown
报错原因:我们下载的Tomcat镜像是精简版的,利用这个镜像去打开一个容器的时候发现没有ip addr这个命令。
解决方式:安装 iproute2:apt install -y iproute2
● 又错误:
-bash: apt: command not found
问题原因:linux的版本造成的,我这个版本使用的是yum,而不是apt
解决:yum install -y iproute2
● 又错误:No package iproute2 available. Error: Nothing to do
★ 解决方式1:安装yum的扩展包epel-release
查看linux版本,下载对应版本的epel-release
# 查看系统的命令:
cat /etc/redhat-release
● 又错误:安装epel-release报错
执行命令 yum -y install https://mirrors.aliyun.com/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm
报错:
Loaded plugins: fastestmirror
epel-release-7-14.noarch.rpm | 15 kB 00:00:00
Examining /var/tmp/yum-root-OIjg1L/epel-release-7-14.noarch.rpm: epel-release-7-14.noarch
/var/tmp/yum-root-OIjg1L/epel-release-7-14.noarch.rpm: does not update installed package.
Error: Nothing to do解决:先使用wget 命令下载,然后再执行yum 命令安装
# 查看 epel 版本信息
命令:rpm -qa|grep epel
epel-release-7-14.noarch
# 卸载老版本的epel-release(若是最新版,这不用版本可以不写,我的刚好就是最新版本的,不然就需要写明卸载epel-release-某个版本)
命令:yum remove epel-release 或者 yum remove epel-release-7-14.noarch
# 安装 epel-release
命令:yum install -y epel-release-7-14.noarch
● 此时,安装iproute2,错误依旧:yum install -y iproute2
No package iproute2 available.
Error: Nothing to do---更换解决方式
★ 方式2:更新yum 源,记得先备份原先的yum源(结果依然无效)
# 进入目录
cd /etc/yum.repos.d/
# 备份:
备份方式1:
mkdir yum.repos.d.backup
cp -r yum.repos.d ./yum.repos.d.backup
备份方式2:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 根据centos版本下载对应的新源【我的centos是版本7的】
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 清空yum缓存
yum clean all
# 生成缓存,会把新下载CentOS-Base.repo源生效
yum makecache
# 更新
yum -y update
我明白了:No package iproute2 available.
Error: Nothing to do。
意思是,找不到可以利用的包(安装包),解决:就是先下载下来 iproute2的安装包,然再安装。
# 下载iproute2的安装包
# 安装iproute2
本题解决方法,早已跑偏,还记得咱的问题是什么吗?
1、了解网络配置工具net-tools与iproute2,发现:net-tools 是老版本linux的网络工具,而iproute2是linux新版本(例如centos7、centos8)的网络工具,
且已经内置,不用手动安装。 "至此,恍然大悟,跑题了,咱是docker 内部没有iproute2,而不是centos系统没有"。可以直接使用网络命令,例如ip addr 等等,查看iproute2的版本命令: ip -V
[root@iZwz9535z41cmgcpkm7i81Z ~]# ip -V
ip utility, iproute2-ss170501
2、iproute2的下载镜像:https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/
★
Docker容器没有ip addr命令:exec ip addr 报错.
报错原因:我们下载的Tomcat镜像是精简版的,利用这个镜像去打开一个容器的时候发现没有ip这个命令。
解决方式:
[先解决安装yum 的问题,再通过yum 安装iproute2] (不对,通过查询docker 容器的系统版本,发现版本是debain,内置的是apt,不是yum)
安装 iproute2:apt install -y iproute2
(1)查看docker 容器的系统版本:cat /etc/os-release
# 系统版本
root@f1cfb81dedfd:/usr/local/tomcat# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/" # 系统版本详情,redhat的命令:cat /etc/redhat-release debain的命令:cat /etc/debian_version
(2)安装 iproute2:
root@f1cfb81dedfd:/usr/local/tomcat# apt install -y iproute2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package iproute2
问题:Unable to locate package:无法找到包。
解决:升级一下 apt,再安装 iproute2
apt update
又报错:
18 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye/InRelease Could not connect to debian.map.fastlydns.net:80 (151.101.74.132), connection timed out Could not connect to deb.debian.org:80 (151.101.110.132), connection timed out
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye-updates/InRelease Unable to connect to deb.debian.org:http:
W: Some index files failed to download. They have been ignored, or old ones used instead.
如果本文对你有帮助的话记得给一乐点个赞哦,感谢!
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ip": executable file not found in $PATH: unknown (Docker容器没有ip addr命令:exec ip addr 报错)的更多相关文章
- docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"ping\": executable file not found in $PATH": unknown.
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting cont ...
- OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "bash": executable file not found in $PATH": unknown
docker save docker save centos:self -o centos.tar 导出镜像到文件 用于持久化镜像,导出的tar包需要用 docker load -i imagedat ...
- /usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:245: running exec setns .....
docker创建容器时报错如下: containerd: start container" error="oci runtime error: container_linux.go ...
- centos7.2部署docker-17.06.0-ce的bug:Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"\"".
现象: 操作系统:centos 7.2 kernel 3.10.0-327.el7.x86_64 mesos:1.3.0 docker:docker-17.06.0-ce 在做mesos验证时,通过m ...
- kolla部署openstack allinone,报错APIError: 500 Server Error: Internal Server Error (\"oci runtime error: container_linux.go:235: starting container process caused \"container init exited prematurely
使用 kolla-ansible 部署 opnenstack:stein 执行 kolla-ansible -i ./all-in-one deploy 开始自动化部署 在部署过程中报错,报错信息如下 ...
- 【解决】OCI runtime exec failed......executable file not found in $PATH": unknown
[问题]使用docker exec + sh进入容器时报错 [root@localhost home]# docker exec -it container-test bash OCI runtime ...
- OCI runtime exec failed: exec failed: unable to start container process: exec: "mongo": executable file not found in $PATH: unknown
前言: 今天按照以往在Docker安装MongoDB的方式安装,但是到最后使用mongo命令执行mongodb命令的时候一直执行不成功,最后还是按照官网的Issues解决了. 创建并运行一个Mongo ...
- exec: "docker-proxy": executable file not found in $PATH
在执行 docker run 操作的时候,一直报如下错误: [root@etcd1 vagrant]# docker run --name redis-6379 -p 6379:6379 -d --r ...
- gogs仓库管理软件 exec: "git-upload-pack": executable file not found in $PATH
当配置完个人中心的ssh公钥的时候,在客户端拉取代码的时候,提示如下错误: Cloning into 'comix-b2m'... Gogs: Internal error fatal: Could ...
随机推荐
- python 元组tuple 增删改查操作
初始化: data_tuple = () data_tuple1 = (1,) data_tuple2 = tuple() 新增: data_tuple+data_tuple1 (data_tuple ...
- 面试问题之C++语言:多态
什么是多态? 概念:同一操作作用于不同的对象,可以有不同的解释,产生不同的执行结果,这就是多态性.简单的说,就是用基类的引用指向子类的对象. 为什么要用多态呢? 原因:封装可以隐藏实现细节,使得代码模 ...
- (转载)mos管电压规格是什么,什么是VMOS管栅极
电压规格:VDSS.VDS.BVDSS.V(BR)DSS VDSS中的"V"表示电压,前面的"D"."S"表示"Drain&quo ...
- 什么是持续集成(CI)?
持续集成(CI)是每次团队成员提交版本控制更改时自动构建和测试代码的过程. 这鼓励开发人员通过在每个小任务完成后将更改合并到共享版本控制存储库来共 享代码和单元测试.
- 利用事件的冒泡特性,为子标签添加Onclick事件
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- centos 后台 运行jar包方法
后台运行jar包方法: 1.nohup java -jar shareniu.jar & nohup意为后台不挂断运行,与是否账号退出无关 2.nohup java -jar shareniu ...
- 【代码开源】GreaterWMS 抖音SDK调用教程
应用介绍 GreaterWMS 抖音SDK调用教程 SDK具体功能: 1,一仓多店,多仓多店 2,库存同步,商品同步 3,快递发货,物流轨迹 4,订单拦截 5,字节云仓 6,精选联盟 7,供应分销 8 ...
- the compatibility problem of ie
ie8hack ie8下的兼容问题处理:背景透明,css3圆角,css3和jquery支持部分css3选择器(例如:nth-child),支持html5的语义化标签,媒体查询@media等. 在htm ...
- 记一次用mpvue框架搭建的小程序
介绍 mpvue (github 地址请参见)是一个使用 Vue.js 开发小程序的前端框架.框架基于 Vue.js 核心,mpvue 修改了Vue.js 的 runtime 和 compiler 实 ...
- 快速安装 kafka 集群
前言 最近因为工作原因,需要安装一个 kafka 集群,目前网络上有很多相关的教程,按着步骤来也能完成安装,只是这些教程都显得略微繁琐.因此,我写了这篇文章帮助大家快速完成 kafka 集群安装. ...