在容器中使用dockerfile安裝vim、telnet、nettools等軟件構建鏡像出現的問題


由於有需要在容器中使用vim,telnet等軟件,所以我們需要在容器內安裝,因為網絡等其他原因,我選擇在Dockerfile里進行安裝

正常安裝:在/etc/apt/sources.list內配置正確的鏡像源即可

RUN echo 'deb http://mirrors.aliyun.com/Debian/ xenial main restricted universe multiverse \n\
           deb http://mirrors.aliyun.com/Debian/ xenial-security main restricted universe multiverse \n\
           deb http://mirrors.aliyun.com/Debian/ xenial-updates main restricted universe multiverse \n\
           deb http://mirrors.aliyun.com/Debian/ xenial-proposed main restricted universe multiverse \n\
           deb http://mirrors.aliyun.com/Debian/ xenial-backports main restricted universe multiverse \n\
           deb-src http://mirrors.aliyun.com/Debian/ xenial main restricted universe multiverse \n\
           deb-src http://mirrors.aliyun.com/Debian/ xenial-security main restricted universe multiverse \n\
           deb-src http://mirrors.aliyun.com/Debian/ xenial-updates main restricted universe multiverse \n\
           deb-src http://mirrors.aliyun.com/Debian/ xenial-proposed main restricted universe multiverse \n\
           deb-src http://mirrors.aliyun.com/Debian/ xenial-backports main restricted universe multiverse \n'\
              > /etc/apt/sources.list
RUN ["apt-get", "update"]
RUN ["apt-get","install","vim","-y"]

但是我這里會出現問題

Err http://deb.debian.org jessie-backports/main amd64 Packages
  404  Not Found
Err http://mirrors.163.com jessie-proposed-updates/main Sources
  404  Not Found [IP: 1.193.221.38 80]
Err http://mirrors.163.com jessie-proposed-updates/non-free Sources
  404  Not Found [IP: 1.193.221.38 80]
Err http://mirrors.163.com jessie-proposed-updates/contrib Sources
  404  Not Found [IP: 1.193.221.38 80]
Err http://mirrors.163.com jessie-proposed-updates/main amd64 Packages
  404  Not Found [IP: 1.193.221.38 80]
Err http://mirrors.163.com jessie-proposed-updates/non-free amd64 Packages
  404  Not Found [IP: 1.193.221.38 80]
Err http://mirrors.163.com jessie-proposed-updates/contrib amd64 Packages
  404  Not Found [IP: 1.193.221.38 80]
Fetched 18.7 MB in 24s (777 kB/s)
W: Failed to fetch http://mirrors.163.com/debian/dists/jessie-proposed-updates/main/source/Sources  404  Not Found [IP: 1.193.221.38 80]

W: Failed to fetch http://mirrors.163.com/debian/dists/jessie-proposed-updates/non-free/source/Sources  404  Not Found [IP: 1.193.221.38 80]

W: Failed to fetch http://mirrors.163.com/debian/dists/jessie-proposed-updates/contrib/source/Sources  404  Not Found [IP: 1.193.221.38 80]

W: Failed to fetch http://mirrors.163.com/debian/dists/jessie-proposed-updates/main/binary-amd64/Packages  404  Not Found [IP: 1.193.221.38 80]

W: Failed to fetch http://mirrors.163.com/debian/dists/jessie-proposed-updates/non-free/binary-amd64/Packages  404  Not Found [IP: 1.193.221.38 80]

W: Failed to fetch http://mirrors.163.com/debian/dists/jessie-proposed-updates/contrib/binary-amd64/Packages  404  Not Found [IP: 1.193.221.38 80]

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-backports/main/binary-amd64/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.
The command 'apt-get update' returned a non-zero code: 100

本以為是源的問題,結果換了一堆源沒有任何用,廢了半天時間,頭疼

后來找到一種解決辦法,還是在Dockerfile內增加

RUN echo "deb [check-valid-until=no] http://cdn-fastly.deb.debian.org/debian jessie main" > /etc/apt/sources.list.d/jessie.list
RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
RUN sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list
RUN apt-get -o Acquire::Check-Valid-Until=false update
RUN apt-get install -y vim
RUN apt-get install -y telnet
RUN apt-get install -y net-tools

我們來試一下

沒問題咯


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM