I am trying to download java using yum on centOs which I specified in Dockerfile.
After pulling centOs image the run crushed and throw this error!?
also to mention that my server instance is AWS EC2!
Step 2/9 : RUN yum install java -y
---> Running in 39fc233aa965
CentOS Linux 8 - AppStream 184 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
The command '/bin/sh -c yum install java -y' returned a non-zero code: 1
10
Answers
If you don’t already have it, you’ll need the gpg keys:
Then it’s as simple as transitioning like so:
Don’t worry — it doesn’t remove any repos, it simply temporarily ignores all of yours, and downloads information regarding the new mirrors.
You may at this point want to actually upgrade your packages:
You’ll now be able to use "yum" as usual.
Try editing your dockerfile
Refer to this code
failed-metadata-repo-appstream-centos-8
I tried to use CentOS 8 with wsl and got the same error. Steps to fix the problem (as root):
The top voted answer did not work for me (by @Hashbrown). The answer with Dockerfile was not for my case either.
Try this
FROM centos
Go to
/etc/yum.repos.d/
directory. Open.repo
file and manually edit mirrorlist from$releasever
to8-stream
.For example : /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
open file in vi
sudo vi /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
comment
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#mirrorlist=http://......
within vi, copy paste
mirrorlist=http://......
lineyy and p
uncomment and edit the copied line by replacing $releasever to 8-stream
mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=$basearch&repo=BaseOS&infra=$infra
save and exit vi
:wq
Repeat above 5-steps for other .repo files.
Go to
/etc/yum.repos.d/
Run
Then do what you want
Please follow the below-mentioned steps:
Go to the /etc/yum.repos.d/ directory.
cd /etc/yum.repos.d/
Run the below commands to hash the mirror-list in all yum.repos.d files then replace the existed Baseurl with the vault.centos.org
sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-*
sed -i ‘s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g’ /etc/yum.repos.d/CentOS-*
Then run yum update or install any package you want
yum update -y
Use these commands to update centOS8.0 on AWS EC2:
CentOS 8 reached EOL on 2021-12-31 (announcement).
Therefore, the URLs to the mirrors don’t work anymore. Instead of using
sed
to modify the URLs to point to the archived mirrors, CentOS officially recommends to convert from CentOS Linux 8 to CentOS Stream 8 via:After that,
dnf
/yum
will work again.Update your docker file with below. It should work.