質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.51%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

yum

yumコマンドは、UNIX系OSのRPMパッケージのインストールなどを行うためのプログラムのことです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

2回答

7482閲覧

Dockerfile内のRUN yum -y install wgetでエラー

user202102

総合スコア9

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

yum

yumコマンドは、UNIX系OSのRPMパッケージのインストールなどを行うためのプログラムのことです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/05/24 03:43

編集2021/05/25 05:48

Docker初心者です。

環境

MacOS 11.2.3
Docker 20.10.6

#Docker for Macバージョン

Client: Cloud integration: 1.0.14 Version: 20.10.6 API version: 1.41 Go version: go1.16.3 Git commit: 370c289 Built: Fri Apr 9 22:46:57 2021 OS/Arch: darwin/arm64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.6 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 8728dd2 Built: Fri Apr 9 22:44:13 2021 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.4.4 GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e runc: Version: 1.0.0-rc93 GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec docker-init: Version: 0.19.0 GitCommit: de40ad0

質問

下記Dockefile内でyum -y install httpdを実行中に、404エラーが出てしまいました。

FROM centos:7 RUN yum update -y RUN yum install -y sudo RUN yum install -y epel-release RUN yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm RUN yum clean all RUN yum clean metadata RUN yum -y install wget RUN yum -y install httpd RUN yum -y install --enablerepo=remi,remi-php73 php php-mbstring php-pdo php-gd php-xml php-mcrypt php-mysql composer RUN yum install -y http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm RUN yum install -y git CMD ["/usr/sbin/httpd", "-DFOREGROUND"]

エラー

Building web [+] Building 158.3s (10/14) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 120B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/centos:7 2.2s => [ 1/11] FROM docker.io/library/centos:7@sha256:0f4ec88e21daf75124b8a9 0.0s => CACHED [ 2/11] RUN yum update -y 0.0s => CACHED [ 3/11] RUN yum install -y sudo 0.0s => CACHED [ 4/11] RUN yum install -y epel-release 0.0s => CACHED [ 5/11] RUN yum install -y http://rpms.famillecollet.com/enter 0.0s => CACHED [ 6/11] RUN yum clean all 0.0s => ERROR [ 7/11] RUN yum -y install wget 156.0s ------ > [ 7/11] RUN yum -y install wget: #10 0.325 Loaded plugins: fastestmirror, ovl #10 0.420 Determining fastest mirrors #10 24.19 * base: ftp.yz.yamagata-u.ac.jp #10 24.19 * epel: nrt.edge.kernel.org #10 24.19 * extras: ftp.yz.yamagata-u.ac.jp #10 24.19 * remi-safe: ftp.riken.jp #10 24.20 * updates: ftp.yz.yamagata-u.ac.jp #10 25.51 https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/safe/aarch64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found #10 25.51 Trying other mirror. #10 25.51 To address this issue please refer to the below wiki article #10 25.51 #10 25.51 https://wiki.centos.org/yum-errors #10 25.51 #10 25.51 If above article doesn't help to resolve this issue please use https://bugs.centos.org/. #10 25.51 #10 25.80 http://ftp.riken.jp/Linux/remi/enterprise/7/safe/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found #10 25.80 Trying other mirror. [略] #10 156.0 http://mirror.innosol.asia/remi/enterprise/7/safe/aarch64/repodata/repomd.xml: [Errno 12] Timeout on http://mirror.innosol.asia/remi/enterprise/7/safe/aarch64/repodata/repomd.xml: (28, 'Connection timed out after 30005 milliseconds') #10 156.0 http://remi.xpg.com.br/enterprise/7/safe/aarch64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: remi.xpg.com.br; Unknown error" ------ executor failed running [/bin/sh -c yum -y install wget]: exit code: 1 ERROR: Service 'web' failed to build : Build failed

検証したこと・実現したいこと

404エラーが出ているページにアクセスしたところ、やはり404エラーになっておりました。http://ftp.riken.jp/Linux/remi/enterprise/7/safe/aarch64/repodata/repomd.xml

正しいページはこちらのようです。
http://ftp.riken.jp/Linux/remi/enterprise/7/safe/x86_64/repodata/

おそらく、参照しているURLが古いままになっているようなので、ここを設定し直すことで解決できるのでは・・?
と思っていますが、解決できる方法があれば教えてきただけると助かります。
Linuxの知識不足もあり解決に時間がかかっております。

補足

Dockefile内の下記記述を修正し実行したがエラーは解消されず。

#FROM centos:7 FROM --platform=linux/x86_64 centos:7

エラー内容

------ > [ 8/12] RUN yum -y install wget: #11 0.731 Loaded plugins: fastestmirror, ovl #11 1.125 Determining fastest mirrors #11 2.624 #11 2.624 #11 2.624 One of the configured repositories failed (Unknown), #11 2.624 and yum doesn't have enough cached data to continue. At this point the only #11 2.624 safe thing yum can do is fail. There are a few ways to work "fix" this: #11 2.624 #11 2.624 1. Contact the upstream for the repository and get them to fix the problem. #11 2.624 #11 2.624 2. Reconfigure the baseurl/etc. for the repository, to point to a working #11 2.624 upstream. This is most often useful if you are using a newer #11 2.624 distribution release than is supported by the repository (and the #11 2.624 packages for the previous distribution release still work). #11 2.624 #11 2.624 3. Run the command with the repository temporarily disabled #11 2.624 yum --disablerepo=<repoid> ... #11 2.624 #11 2.624 4. Disable the repository permanently, so yum won't use it by default. Yum #11 2.624 will then just ignore the repository until you permanently enable it #11 2.624 again or use --enablerepo for temporary usage: #11 2.624 #11 2.624 yum-config-manager --disable <repoid> #11 2.624 or #11 2.624 subscription-manager repos --disable=<repoid> #11 2.624 #11 2.624 5. Configure the failing repository to be skipped, if it is unavailable. #11 2.624 Note that yum will try to contact the repo. when it runs most commands, #11 2.624 so will have to try and fail each time (and thus. yum will be be much #11 2.624 slower). If it is a very temporary problem though, this is often a nice #11 2.624 compromise: #11 2.624 #11 2.624 yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true #11 2.624 #11 2.624 Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

ベストアンサー

どこからインストールされるかはミラーリストから選択されます。
URLの一部は下記のように変数$basearchを参照するようになっていますが、aarch64アーキテクチャのOSが利用されていることでここがaarch64にセットされています
(例)http://rpms.remirepo.net/enterprise/7/safe/$basearch/

aarch64のCentOSイメージを利用されているようですが、x86_64のCentOSイメージを利用するとよいと思います

投稿2021/05/24 04:35

yukky1201

総合スコア2751

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

user202102

2021/05/24 04:58

ありがとうございます。 x86_64のCentOSイメージを利用する、ということはFROM centos:7の部分で指定するということでしょうか。 となると、公式からx86_64のCentOSイメージであることを確認してそれを指定してあげればいいということになるかと認識しております。 https://hub.docker.com/layers/centos/library/centos/7/images/sha256-e4ca2ed0202e76be184e75fb26d14bf974193579039d5573fb2348664deef76e?context=explore
yukky1201

2021/05/24 05:13

リンク先のOS/ARCHにて「linux/amd64」を選択するとx86_64アーキテクチャのCentOSとなると思います
user202102

2021/05/24 06:20

重ねてありがとうございます。 dock pull でリンク先のlinux/amd64を選択しコマンド後、再度上記Dockerfileを実行しましたがaarch64のままになってしまいました。なにか間違った手順をおこなってしまったのでしょうか。 M1チップ搭載のMacだからそうなっている。。のかもしれないです。
user202102

2021/05/24 07:25

buildしてみましたが、実行途中で同じようにyum -y install httpdでエラーが出てしまいました。 URLがaarch64のままです。 M1チップはx86_64プラットフォームを使用する場合はを明示しないと行けないようですので、下記の通りに修正して試してみましたが、今度は別のエラーが発生してしまいました。(補足に追記します。) 参考サイト https://zenn.dev/chimerast/articles/efae877853e837 https://memo.koumei2.com/m1%E3%83%81%E3%83%83%E3%83%97%E3%81%AE-mac-mini-%E3%81%A7-docker%E3%82%92%E4%BD%BF%E3%81%86/
yukky1201

2021/05/24 07:52

なるほど、M1チップはarm64なので今回の事象となっているのですね。 linuxのイメージが「linux/amd64」でしたので、「--platform linux/amd64」で指定(x86_64ではなく)した場合はどうでしょうか 参考 https://zenn.dev/chimerast/articles/efae877853e837
user202102

2021/05/24 08:27

試してみましたが、下記の通り今度はそもそも処理が実行できなくなってしまいました。 ``` Building web [+] Building 0.1s (2/2) FINISHED => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 886B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 2: FROM requires either one or three arguments ERROR: Service 'web' failed to build : Build failed ```
yukky1201

2021/05/24 09:06

先ほどのオプション指定にて誤記がありました。=でつないでみてください (誤) --platform linux/amd64 (正) --platform=linux/amd64
user202102

2021/05/24 09:19

正しい記載をしましたが、結果は変わらず・・・です。
yukky1201

2021/05/24 11:18

failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 2: FROM requires either one or three arguments と出力されていますので、FROMの書式を確認してください
user202102

2021/05/25 00:56

FROMを見直して再度実行してみましたが、補足と同様のエラーが発生してしまいました。
yukky1201

2021/05/25 02:05

docker pull --platform linux/amd64 centos:7 でイメージをプラットフォーム指定でダウンロードしておいて、 dockerfileではそのイメージを使用する(FROM centos:7)するとどうでしょうか
user202102

2021/05/25 06:18

上記試してみましたが、最初に表示されたエラーが出てきてしまいました。 URLはaarch64のままです。 また、FROM centos:7の部分でプラットフォームを明示しないと、(yumの部分をすべて削除してエラーがでないようにして)作成したコンテナでは、x86_64のCentOSのイメージを使っているとしてもarm64に変わってしまっていました。 ひとまず、CentOSのイメージからコマンドを実行したところなんとかインストールできたので、これで対応できるか検討してみたいと思います。 Dockerのバージョンを追記しましたが、Docker Engineのアーキテクチャも影響しているんでかね。。。
yukky1201

2021/05/25 08:42

x86_64のCentOSのイメージを使っているときに、uname -aにて出力されるのはaarch64、x86_64どちらでしょうか。このときのアーキテクチャが本件のキモだと思います (x86_64の場合の例) [root@localhost ~]# uname -a Linux localhost.localdomain 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux M1搭載Macを所有していないので検証ができず、これ以上の解決案の提示は難しいです。 「M1搭載Macでx86_64を使えるようにする」という観点で調査してもらえればと思います。
user202102

2021/05/27 05:01

返信遅れて申し訳ございません。 問題は解決しましたので自己解決に記載しますが、uname -aで出力されるのはx86_64で内容も上記と一緒でした。 FROMでプラットホームを指定すればちゃんとx86_64をイメージが使われるようです。 本件、色々とアドバイスいただきありがとうございましたので、ベストアンサーとさせていただきます。
guest

0

yum install -y epel-releaseした後にyumが動作していなかったことが判明したので、
下記サイトを参考に、epel.repoを編集することで、yumが正常に動作し参照するリポジトリも正しくなりました。

https://www.mapleharp.jp/342/

投稿2021/05/27 05:05

user202102

総合スコア9

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.51%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問