事象
ruby:2.4.1-slim-stretch
のDockerイメージビルド時に以下のエラーが発生。
エラーは先頭でビルドに必要なパッケージ群をインストールする箇所で発生していた。
Dockerfile
RUN apt-get update && apt-get install XXXXX
$ docker build XXXX
:
E: Failed to fetch http://security.debian.org/dists/stretch/updates/main/binary-arm64/Packages 404 Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-arm64/Packages 404 Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-arm64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: executor failed running [/bin/sh -c apt-get update && apt-get install XXXXX]: exit code: 100
原因
ruby:2.4.1-slim-stretch
のLinux OSディストリビューションであるDebianのバージョンが古く、パッケージのインデックスファイルの置き場所が変更されてしまっているため。
/etc/apt/sources.list
deb http://deb.debian.org/debian stretch main
deb http://deb.debian.org/debian stretch-updates main
deb http://security.debian.org stretch/updates main
対処方法(暫定)
デッドリンクになっているライブラリ一覧の向き先をアーカイブのホストに変更すればOK。
/etc/apt/sources.list
の記述を上書きする。
/etc/apt/sources.list
deb http://deb.debian.org/debian stretch main
deb http://deb.debian.org/debian stretch-updates main
deb http://security.debian.org stretch/updates main
↓↓↓↓↓
/etc/apt/sources.list
deb http://archive.debian.org/debian/ stretch main
deb http://archive.debian.org/debian-security stretch/updates main
つまり、以下のようにDockerfileのRUNを書き換えれば良い。
Dockerfile
RUN apt-get update && apt-get install XXXXX
↓↓↓↓↓
Dockerfile
RUN echo "deb http://archive.debian.org/debian/ stretch main" > /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install XXXX
- 参考:アーカイブのURL(バージョン:stretch、アーキテクチャ:amd64)
対処方法(恒久)
利用しているDocker ImageのDebianバージョンが古いことが根本原因のため、Rubyのパッチバージョンを上げてDebianバージョンも安定版に上げる。
これにより、アーカイブ参照は(当面は)不要となる。
Debian:bullseye / Ruby:2.7.7
※動作確認は必要