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
asked Feb 2, 2022 at 23:01
1
Try editing your dockerfile
FROM centos
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum -y install java
CMD /bin/bash
Refer to this code
failed-metadata-repo-appstream-centos-8
answered Mar 1, 2022 at 13:28
BigCatBigCat
1,2611 gold badge2 silver badges4 bronze badges
5
If you don’t already have it, you’ll need the gpg keys:
wget 'http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-3.el8.noarch.rpm'
sudo rpm -i 'centos-gpg-keys-8-3.el8.noarch.rpm'
Then it’s as simple as transitioning like so:
dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos
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:
sudo dnf distro-sync
You’ll now be able to use «yum» as usual.
answered Feb 7, 2022 at 14:44
HashbrownHashbrown
11.6k8 gold badges71 silver badges90 bronze badges
1
Go to /etc/yum.repos.d/
cd /etc/yum.repos.d/
Run
sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
sudo yum update -y
Then do what you want
answered Apr 24, 2022 at 2:39
wsdzbmwsdzbm
2,8093 gold badges23 silver badges26 bronze badges
2
I tried to use CentOS 8 with wsl and got the same error. Steps to fix the problem (as root):
# 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-*
# dnf distro-sync
# dnf -y install java
The top voted answer did not work for me (by @Hashbrown). The answer with Dockerfile was not for my case either.
answered Mar 23, 2022 at 11:16
4
Use these commands to update centOS8.0 on AWS EC2:
sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g"
-e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g"
/etc/yum.repos.d/CentOS-*
tripleee
170k31 gold badges261 silver badges306 bronze badges
answered Jun 16, 2022 at 8:49
sfl0r3nz05sfl0r3nz05
3875 silver badges12 bronze badges
0
CentOS 8 reached EOL on 2021-12-31 (announcement).
Therefor, 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:
dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
dnf distro-sync
After that, dnf/yum will work again.
answered Aug 1, 2022 at 6:44
stackprotectorstackprotector
8,9774 gold badges29 silver badges58 bronze badges
Try this
FROM centos
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum -y install java
CMD /bin/bash
answered Mar 23, 2022 at 22:16
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
answered May 30, 2022 at 8:35
MahmudMahmud
1111 silver badge7 bronze badges
0
Update your docker file with below. It should work.
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum update -y
answered Jan 5 at 19:21
viratpuarviratpuar
5141 gold badge5 silver badges22 bronze badges
Go to /etc/yum.repos.d/ directory. Open .repo file and manually edit mirrorlist from $releasever to 8-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.
answered Apr 15, 2022 at 11:02
SathishSathish
12.3k3 gold badges41 silver badges58 bronze badges
I had installed a minimalist CentOS 8 on one of my servers. Installation went successful, however, when I tried to update the system using yum update I see this error message: Failed to download metadata for repo. Below is the complete error.
[root@autocontroller ~]# yum update CentOS-8 - AppStream 70 B/s | 38 B 00:00 Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
Output from the /var/log/dnf.log for more DEBUG information:
2022-02-02T11:39:36Z DEBUG error: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org] (http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock). 2022-02-02T11:39:36Z WARNING 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=stock [Could not resolve host: mirrorlist.centos.org] 2022-02-02T11:39:36Z DDEBUG Cleaning up. 2022-02-02T11:39:36Z SUBDEBUG Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 573, in load ret = self._repo.load() File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 394, in load return _repo.Repo_load(self) RuntimeError: 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=stock [Could not resolve host: mirrorlist.centos.org]
But, then verified with the internet connection and DNS and it works just fine as below:
[root@autocontroller ~]# ping google.com PING google.com (172.217.166.206) 56(84) bytes of data. 64 bytes from del03s13-in-f14.1e100.net (172.217.166.206): icmp_seq=1 ttl=115 ti me=43.5 ms --- google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 43.508/43.508/43.508/0.000 ms
So how did I fix the issue? Here it is.
CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. It means that CentOS 8 will no longer receive development resources from the official CentOS project. After Dec 31st, 2021, if you need to update your CentOS, you need to change the mirrors to vault.centos.org where they will be archived permanently. Alternatively, you may want to upgrade to CentOS Stream.
Step 1: Go to the /etc/yum.repos.d/ directory.
[root@autocontroller ~]# cd /etc/yum.repos.d/
Step 2: Run the below commands
[root@autocontroller ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@autocontroller ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Step 3: Now run the yum update
[root@autocontroller ~]# yum update -y
That’s it!
Ramya Santhosh
is a Web Designer and content creator. A freelance writer on latest trends in technology, gadget reviews, How to’s and many more.
-
jobe
- Posts: 2
- Joined: 2020/10/26 10:55:07
CentOS 8: Failed to download metadata for repo ‘appstream’
Hi everybody, on my CentOS 8 server (CentOS Linux release 8.5.2111) today I used «dnf update» command, but I received this error:
Code: Select all
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
The server is connected to the internet and can download files.
Since CentOS 8 is EOL, have they changed or removed CentOS 8 repos? I did not find any confirmation on centos site. Do you have any clue?
-
TrevorH
- Site Admin
- Posts: 32532
- Joined: 2009/09/24 10:40:56
- Location: Brighton, UK
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by TrevorH » 2022/01/31 11:19:38
CentOS 8 went EOL at the end of December and in line with all the public announcements, the content of the CentOS 8 repos has been moved to vault.centos.org.
It’s time to move to something else.
-
jobe
- Posts: 2
- Joined: 2020/10/26 10:55:07
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by jobe » 2022/01/31 12:02:10
Thanks for the clarification. Yes, I am migrating to Rocky
-
TrevorH
- Site Admin
- Posts: 32532
- Joined: 2009/09/24 10:40:56
- Location: Brighton, UK
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by TrevorH » 2022/01/31 20:37:35
The correct and easy way to migrate from CentOS Linux 8 to CentOS Stream 8 is to run:
Code: Select all
dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos
dnf distro-sync
[Edited with the v2 version of how to…]
-
Egyas
- Posts: 1
- Joined: 2022/01/31 22:26:03
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by Egyas » 2022/01/31 22:28:18
I created an account here JUST so that I could say «THANK YOU!» for this post.
-
jlehtone
- Posts: 4252
- Joined: 2007/12/11 08:17:33
- Location: Finland
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by jlehtone » 2022/01/31 22:40:11
If Stream feels like a too distant cousin, the «siblings» (RHEL, Alma, Rocky, OL) surely have «sidegrade» scripts.
-
TrevorH
- Site Admin
- Posts: 32532
- Joined: 2009/09/24 10:40:56
- Location: Brighton, UK
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by TrevorH » 2022/01/31 23:00:50
I created an account here JUST so that I could say «THANK YOU!» for this post.
![]()
Even though it’s the wrong solution?
-
avoulvou
- Posts: 5
- Joined: 2022/01/31 20:24:35
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by avoulvou » 2022/02/01 16:45:35
TrevorH wrote: ↑
2022/01/31 20:37:35
The correct and easy way to migrate from CentOS Linux 8 to CentOS Stream 8 is to run:Code: Select all
dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos dnf distro-sync[Edited with the v2 version of how to…]
Hi,
you have missed the most important the links dont work any more
So the initial step is
Change url to vault
Else you will have
[root@srv1 ~]# dnf update
CentOS Linux 8 — AppStream 271 B/s | 38 B 00:00
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
[root@srv1 ~]# dnf —disablerepo ‘*’ —enablerepo=extras swap centos-linux-repos centos-stream-repos
CentOS Linux 8 — Extras 40 kB/s | 1.5 kB 00:00
CentOS Linux 8 — Extras 254 kB/s | 10 kB 00:00
Modular dependency problems:
Problem 1: conflicting requests
— nothing provides module(perl:5.26) needed by module perl-DBI:1.641:8030020200716150652:1e4bbb35-0.x86_64
Problem 2: conflicting requests
— nothing provides module(perl:5.26) needed by module perl-IO-Socket-SSL:2.066:8030020201222215140:1e4bbb35-0.x86_64
Problem 3: conflicting requests
— nothing provides module(perl:5.26) needed by module perl-libwww-perl:6.34:8030020201223164340:b967a9a2-0.x86_64
Error:
Problem 1: conflicting requests
— nothing provides centos-gpg-keys = 1:8-3.el8 needed by centos-stream-repos-8-3.el8.noarch
Problem 2: package centos-linux-release-8.4-1.2105.el8.noarch requires centos-repos(8), but none of the providers can be installed
— conflicting requests
— problem with installed package centos-linux-release-8.4-1.2105.el8.noarch
— nothing provides centos-gpg-keys = 1:8-3.el8 needed by centos-stream-repos-8-3.el8.noarch
(try to add ‘—skip-broken’ to skip uninstallable packages or ‘—nobest’ to use not only best candidate packages)
and will crash if you try to continue
after that you can proceed with one option or another
-
TrevorH
- Site Admin
- Posts: 32532
- Joined: 2009/09/24 10:40:56
- Location: Brighton, UK
Re: CentOS 8: Failed to download metadata for repo ‘appstream’
Post
by TrevorH » 2022/02/01 16:47:16
No, you didn’t read the command. It disables ALL repos then enables ONLY the extras repo which is the only CentOS Linux 8 repo still working. There is no need to change the baseurls to vault since it disables all the repos.
You do need the system to be up to date enough to have the latets centos-gog-keys package installed.
I’m on a fresh Centos 8 install and have tried to use yum for the first time (on this machine). I get the following for any attempt to install or update anything:
yum update
CentOS-8 - AppStream 0.0 B/s | 0 B 00:00
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'
Port 80 is open although nmap reports it as closed presumably because I haven’t yet installed apache. To be double sure I have added port 80 to firewalld which is confirmed:
firewall-cmd --list-ports
25/tcp 80/tcp
I have tried various advice like yum clean and clearing the yum cache but nothing helps.
This is what is in the dnf.log:
2020-03-30T19:33:01Z INFO --- logging initialized ---
2020-03-30T19:33:01Z DDEBUG timer: config: 4 ms
2020-03-30T19:33:01Z DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
2020-03-30T19:33:01Z DEBUG DNF version: 4.2.7
2020-03-30T19:33:01Z DDEBUG Command: yum install httpd
2020-03-30T19:33:01Z DDEBUG Installroot: /
2020-03-30T19:33:01Z DDEBUG Releasever: 8
2020-03-30T19:33:01Z DEBUG cachedir: /var/cache/dnf
2020-03-30T19:33:01Z DDEBUG Base command: install
2020-03-30T19:33:01Z DDEBUG Extra commands: ['install', 'httpd']
2020-03-30T19:33:01Z DEBUG repo: downloading from remote: AppStream
2020-03-30T19:33:02Z DEBUG error: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org] (http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock).
2020-03-30T19:33:02Z DEBUG Cannot download 'http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock': 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=stock [Could not resolve host: mirrorlist.centos.org].
2020-03-30T19:33:02Z ERROR Failed to download metadata for repo 'AppStream'
2020-03-30T19:33:02Z DDEBUG Cleaning up.
2020-03-30T19:33:02Z SUBDEBUG
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 552, in load
ret = self._repo.load()
File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 394, in load
return _repo.Repo_load(self)
RuntimeError: Failed to download metadata for repo 'AppStream'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 65, in main
return _main(base, args, cli_class, option_parser_class)
File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 98, in _main
return cli_run(cli, base)
File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 114, in cli_run
cli.run()
File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1134, in run
self._process_demands()
File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 832, in _process_demands
load_available_repos=self.demands.available_repos)
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 406, in fill_sack
self._add_repo_to_sack(r)
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 136, in _add_repo_to_sack
repo.load()
File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 558, in load
raise dnf.exceptions.RepoError(str(e))
dnf.exceptions.RepoError: Failed to download metadata for repo 'AppStream'
2020-03-30T19:33:02Z CRITICAL Error: Failed to download metadata for repo 'AppStream'

