替换docker容器默认的debian镜像

半兽人 发表于: 2020-04-29   最后更新时间: 2020-04-29  

在容器里执行apt-get命令时候,报如下错误,替换国内的镜像源即可。

apt-get install net-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package net-tools
root@cloud-front-769f97f7b8-mvzjp:/# apt-get update           
Ign http://security.debian.org wheezy/updates Release.gpg                      
Ign http://security.debian.org wheezy/updates Release                          
Get:1 http://nginx.org wheezy Release.gpg [287 B]                      
Get:2 http://nginx.org wheezy Release [2343 B]                                 
Ign http://nginx.org wheezy Release                                            
Get:3 http://nginx.org wheezy/nginx amd64 Packages [31.9 kB]            
Err http://security.debian.org wheezy/updates/main amd64 Packages              

Err http://security.debian.org wheezy/updates/main amd64 Packages              

Err http://security.debian.org wheezy/updates/main amd64 Packages              

Err http://security.debian.org wheezy/updates/main amd64 Packages              

Err http://security.debian.org wheezy/updates/main amd64 Packages
  404  Not Found [IP: 151.101.128.204 80]
Ign http://http.debian.net wheezy Release.gpg                   
Ign http://http.debian.net wheezy-updates Release.gpg
Ign http://http.debian.net wheezy Release
Ign http://http.debian.net wheezy-updates Release
Err http://http.debian.net wheezy/main amd64 Packages                          

Err http://http.debian.net wheezy-updates/main amd64 Packages                  

Err http://http.debian.net wheezy/main amd64 Packages                          

Err http://http.debian.net wheezy-updates/main amd64 Packages                  

Err http://http.debian.net wheezy/main amd64 Packages                          

Err http://http.debian.net wheezy-updates/main amd64 Packages                  

Err http://http.debian.net wheezy/main amd64 Packages                          

Err http://http.debian.net wheezy-updates/main amd64 Packages                  

Err http://http.debian.net wheezy/main amd64 Packages                          
  404  Not Found
Err http://http.debian.net wheezy-updates/main amd64 Packages                  
  404  Not Found
Fetched 34.6 kB in 12s (2774 B/s)                                              
W: GPG error: http://nginx.org wheezy

使用163的源

# 更新apt-get源
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list

使用阿里云的源

# 更新apt-get源
mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://mirrors.aliyun.com/debian stretch main contrib non-free" >/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free" >>/etc/apt/sources.list


您需要解锁本帖隐藏内容请: 点击这里
本帖隐藏的内容




上一条: NetworkPolicy网络策略入门例子 - kubernetes
下一条: Kubernetes imagePullPolicy拉取策略