添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
近视的乌冬面  ·  XMLHttpRequest ...·  8 月前    · 
爽快的小蝌蚪  ·  android base64 ...·  9 月前    · 
面冷心慈的水煮鱼  ·  关于 ...·  9 月前    · 

https://hub.docker.com/layers/library/node/12.0/images/sha256-d97e1f326ca9ebdebfaaf6cc7252cce69e327e9b243faa37462e59fd2d93c025?context=explore

我用的Docker映像檔是「node:12.0」。這是一個2019年的映像檔,作業系統是Debian 9 (stretch)。

https://wiki.debian.org/LTS

Stretch的支援時期僅到2022年6月30日。在現今2023年的時候,它已經不在支援列表了。

因此當我們在Strectch直接執行「apt-get update」的時候,就會看到以下錯誤訊息:

Reading package lists...
W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

這是因為原本作業系統要連上Debian伺服器去檢查的更新資訊,現在已經被移除的關係。

遇到這種情況要怎麼辦好呢?

修改更新網址 / Modify the sources.list

https://stackoverflow.com/a/76095392

Alain Hernandez為Docker的使用者提供了一套解法。請在執行「apt-get update」之前,加上以下程式碼,以此修改更新網址:

#Update stretch repositories
RUN sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
RUN sed -i 's|security.debian.org|archive.debian.org/|g' /etc/apt/sources.list
RUN sed -i '/stretch-updates/d' /etc/apt/sources.list

上述的做法是把更新網址從與原本的「security」改成了「archive」,這樣即使系統無法安裝最新版套件,至少也還能安裝之前的套件。

為了避免下次再遇到這樣的問題,我還是來把Docker映像檔備份一下好了orz

最後要來問的問題是:你在編譯Dockerfile最常遇到的問題是什麼呢?

歡迎在下面分享喔!

在Docker舊版Debian裡安裝套件 / How to Handle the "Failed to fetch" Error When Running "apt-get update"? 布丁布丁吃布丁 製作,以 創用CC 姓名標示-非商業性-相同方式分享 3.0 台灣 授權條款 釋出。