场景:基于 Dockerfile 创建一个最基本的 httpd 镜像
报错代码如下:
[root@localhost ~]docker build -t httpd:centos .
...
...
Step 3/9 : RUN yum -y update
---> [Warning] IPv4 forwarding is disabled. Networking will not work.
---> Running in a0a858748903
CentOS Linux 8 - AppStream 0.0 B/s | 0 B 04:00
Errors during downloading metadata for repository 'appstream':
- Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
The command '/bin/sh -c yum -y update' returned a non-zero code: 1
在执行【RUN yum -y update】时出错
[root@localhost ~]# yum update
'//升级所有包同时也升级软件和系统内核'
已加载插件:fastestmirror, langpacks
/var/run/yum.pid 已被锁定,PID 为 7082 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存:157 M RSS (1.1 GB VSZ)
已启动: Wed Mar 24 11:36:37 2021 - 07:03之前
状态 :睡眠中,进程ID:7082
--
现象:使用不成功,然后使用别的yum命令也不行!
--
直观现象就是使用不了 yum,报错提示'/var/run/yum.pid'被锁住了,现去查看文件一下
[root@localhost ~]# cat /var/run/yum.pid
7082[root@localhost ~]#
--
百度完解决办法,但是自己也别的头绪,删除下该文件再试试
rm -f /var/run/yum.pid
--
再就能够成功运行yum了!
再次使用【yum update】时建议使用在线源进行