docker-compose buildでエラー 原因はCentOS7が非推奨のため


# 背景
LPIC102の学習でCentOS7 on Dockerを使っていたところ発生しました。


# 症状
bashでdocker-compose buildを実行した所、packageがダウンロードされない。
```docker:dockerfile
FROM centos:7
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN yum update -y
RUN  yum install -y  net-tools
RUN yum install -y systemd
RUN  yum install -y  rsyslog
# RUN  yum install -y  source
RUN  yum install -y  zsh
RUN yum install -y postfix
RUN yum install -y mailx
RUN yum install -y traceroute
RUN yum install -y iproute
RUN yum install -y  xinetd
RUN yum -y install lsof
RUN yum -y install nmap
# デフォルトだとrootの実行権限がないので、
RUN groupadd docker -g 1000
RUN usermod root -G 1000

```

以下エラー文
## エラー文
```
docker-compose build
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
http://ftp.riken.jp/Linux/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://ftp-srv2.kddilabs.jp/Linux/packages/CentOS/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://ftp.tsukuba.wide.ad.jp/Linux/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://mirrors.cat.net/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://mirror.aktkn.sg/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://download.nus.edu.sg/mirror/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://ftp.nara.wide.ad.jp/pub/Linux/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
Resolving Dependencies
--> Running transaction check
---> Package nmap.x86_64 2:6.40-19.el7 will be installed
--> Processing Dependency: nmap-ncat = 2:6.40-19.el7 for package: 2:nmap-6.40-19.el7.x86_64
--> Processing Dependency: libpcap.so.1()(64bit) for package: 2:nmap-6.40-19.el7.x86_64
--> Running transaction check
---> Package libpcap.x86_64 14:1.5.3-13.el7_9 will be installed
---> Package nmap-ncat.x86_64 2:6.40-19.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================= Package                                Arch                                Version                                         Repository                            Size 
=======================================================================================================================================================================Installing:
 nmap                                   x86_64                              2:6.40-19.el7                                   base                                 3.9 M 
Installing for dependencies:
 libpcap                                x86_64                              14:1.5.3-13.el7_9                               updates                              139 k 
 nmap-ncat                              x86_64                              2:6.40-19.el7                                   base                                 206 k 

Transaction Summary
=======================================================================================================================================================================Install  1 Package (+2 Dependent packages)

Total size: 4.3 M
Total download size: 139 k
Installed size: 17 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp.riken.jp/Linux/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp-srv2.kddilabs.jp/Linux/packages/CentOS/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found-:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp.tsukuba.wide.ad.jp/Linux/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found 0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://mirrors.cat.net/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found 0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found    0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://mirror.aktkn.sg/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found 0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://download.nus.edu.sg/mirror/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found   0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found |    0 B  --:--:-- ETA 
Trying other mirror.
libpcap-1.5.3-13.el7_9.x86_64. FAILED
http://ftp.nara.wide.ad.jp/pub/Linux/centos/7.9.2009/updates/x86_64/Packages/libpcap-1.5.3-13.el7_9.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found0 B  --:--:-- ETA 
Trying other mirror.


Error downloading packages:

```

# 原因
2024/6/30の時点でCentOS7のサポートが終了し非推奨になったため。
非推奨になり、ダウンロード先のURL上にファイルを置かなくなった（と考えられます。）


## 具体例 山形大学のurlの場合
コンソール画面で表示されたURLの一つを試しに調べてみます。
今回は最初に表示された山形大学のurlを調べてみます。

https://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/7.9.2009/
readme ファイルのみが置かれています。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2710623/647db1c9-ce06-5d6a-9df5-da57ba9c3a8c.png)

readmeの内容が以下のとおりです。
```readme.txt
This directory (and version of CentOS) is deprecated. 

```

# 対処
dockerfileのimageをrockylinux:8に変更する

```diff_docker:dockerfile
+FROM rockylinux:8
-FROM centos:7
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN yum update -y
RUN  yum install -y  net-tools
RUN yum install -y systemd
RUN  yum install -y  rsyslog
# RUN  yum install -y  source
RUN  yum install -y  zsh
RUN yum install -y postfix
RUN yum install -y mailx
RUN yum install -y traceroute
RUN yum install -y iproute
RUN yum install -y  xinetd
RUN yum -y install lsof
RUN yum -y install nmap
# デフォルトだとrootの実行権限がないので、
RUN groupadd docker -g 1000
RUN usermod root -G 1000

```

# 参考
## REDHAT告知
cetnos7 サポート終了

https://www.redhat.com/ja/topics/linux/centos-linux-eol

## github変更箇所

https://github.com/RYA234/LPIC102_Learning/commit/ad8f07619fd841b1fd0b357f9c261cacc59dfdff