用docker 下载nginx报错记录,及解决办法。
原因:
该错误是指错误创建容器,无法检索OCI运行时错误。
由于我们的docker,没有runc这个运行工具,导致无法启动容器。
解决:
1. 查看runc是否存在
docker version
版本号会出现runc版本,没有则表示该工具不存在在需手动安装。
2. 查看runc版本
runc --version
这里可能会报错:runc: symbol lookup error: runc: undefined symbol: seccomp_api_get
这个错误信息表明 runc
在运行时找不到 seccomp_api_get
符号,这通常是由于系统缺少必要的库或库版本不兼容导致的。
runc
工具依赖于其他软件包, libseccomp
3. 查看libseccomp 是否存在
在 CentOS/RHEL 上:
rpm -qa | grep libseccomp
我的版本为libseccomp-2.3.3-3.el8.x86_64
次版本太旧无法支持runc运行,我们更新此版本
4. 更新 libseccomp
sudo yum update libseccomp
这里大概率会报错,也是最棘手的地方。
报错:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager t
原因:
redhat yum源更新更新依赖是收费的,所以我们切换centos 的yum源
1、RedHat yum源是收费的,没有成功注册RH的机器是不能正常使用yum的;
2、CentOs yum源是免费的,可以使用国内网易的yum源,比较稳定;
解决:切换centos 的yum源
1. 查看redhat版本 和系统位数
[root@localhost nginx]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.0 (Ootpa)
[root@localhost nginx]# arch
x86_64
2. .检查是否安装yum包。查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:
rpm -qa |grep yum
3. 删除redhat自带的yum包
rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)
rpm -qa |grep yum (查询确认)
4. 由于CentOS 6 7 各大镜像网站都停止维护,我们采用CentOS 8 的yum源
确保你的虚拟机能联外网:ping www.baidu.com
5. 去阿里云下载 yum安装所需的仓库 配置文件 .repo,选择CentOS8 即可下载
6. 下载后上传到 linux系统下面的/etc/yum.repo.d/,备份该文件,修改这份上传的文件
更改内容:
1)将无效的网络地址删除掉或者注释(本文中采用删除的方式,将内网地址删除掉)
2)将文中的$releasever 替换成 要采用的redhat系统版本号(本文的为8)
修改后的文件如下:
[root@bogon ~]# cat /etc/yum.repos.d/Centos-8.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-8- Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/8/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that may be useful
[extras]
name=CentOS-8- Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/8/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-8- Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/8/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=CentOS-8- PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/8/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-8- AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/8/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[root@bogon ~]#
7. 清理yum缓存
yum clean all
报错:
-bash: /usr/bin/yum: No such file or directory 没有文件或者文件夹
解决方法:需要安装yum命令。执行如下命令:
解决:
这需要先安装yum,这里用CentOS8的yum源
rpm -ivh --nodeps https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Packages/yum-4.7.0-4.el8.noarch.rpm
【注意】后面的.rpm文件可能会随着官网的变化而变化,到官网查看最新的文件名,替换上去即可
8. 查看yum当前所用的库
yum repolist all
表示yum 源替换成功,能正常下载文件和更新 libseccomp
了
9. 将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
yum makecache
5. 再次查看 libseccomp版本并更新
此时查看docker 版本就能看见runc工具的版本号了
6. 重启docker 后,启动nginx
systemctl restart docker
docker run -p 9002:80 --name nginx
-v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
-v /home/nginx/conf/conf.d:/etc/nginx/conf.d
-v /home/nginx/log:/var/log/nginx
-v /home/nginx/html:/usr/share/nginx/html
-d nginx:latest