← Back to list

How to fix error: Cannot find a valid baseurl for repo: base/7/x86_64 Error: building at STEP “RUN…

I was facing the same issue while building an image using this dockerfile

fsdarvind · 2024-11-13 02:46 · 0 claps · 0.6 min read
#dockerfiles #centos7 #yum #httpd
Open on Medium ↗
Wiki topics: ML · Machine Learning ☁️ · DevOps & Cloud

How to fix error: Cannot find a valid baseurl for repo: base/7/x86_64

Error: building at STEP “RUN yum install httpd -y”: while running runtime: exit status 1

I was facing the same issue while building an image using this dockerfile

FROM centos:7
RUN yum install httpd -y
RUN echo "This is v1 of our app...">/var/www/html/index.html
CMD httpd -DFOREGROUND

So I modified the docker file as follows

FROM centos:7
RUN 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-* && \
  yum update -y && \
  yum install httpd -y
RUN echo "This is v1 of our app...">/var/www/html/index.html
CMD httpd -DFOREGROUND

This fixed my issue.

RUN 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-* && \
  yum update -y &&

These commands fix repository access issues by using a stable source (vault.centos.org) instead of dynamic mirrors, which often fail due to network/DNS problems.


메타데이터
post_id
f0350dfeaf09
slug
how-to-fix-error-cannot-find-a-valid-baseurl-for-repo-base-7-x86-64-error-building-at-step-run-f0350dfeaf09
url
https://medium.com/@fsdarvind/how-to-fix-error-cannot-find-a-valid-baseurl-for-repo-base-7-x86-64-error-building-at-step-run-f0350dfeaf09
canonical_url
https://medium.com/@fsdarvind/how-to-fix-error-cannot-find-a-valid-baseurl-for-repo-base-7-x86-64-error-building-at-step-run-f0350dfeaf09
author_url
https://medium.com/@fsdarvind
status
ok
fetched_at
2026-06-27 23:56:40