docker容器内部设置apt源和网络代理

docker容器内部设置apt源和网络代理

# 进入容器,并更新容器的apt源
[root@server01 ~]# docker exec -it mynginx /bin/bash

# 更新nginx的apt源
tee /etc/apt/sources.list << EOF
deb http://mirrors.163.com/debian/ jessie main non-free contrib
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
EOF

 

# 相关的debian镜像站

tee /etc/apt/sources.list << EOF
deb http://ftp.hk.debian.org/debian/ jessie main non-free contrib
deb http://ftp.hk.debian.org/debian/ jessie-updates main non-free contrib
EOF


全球debian镜像站列表

https://www.debian.org/mirror/list.zh-cn.html

设置apt-get的代理
cd /etc/apt
echo 'Acquire::http::Proxy "http://10.11.0.148:808";' >> apt.conf
echo 'Acquire::https::proxy "http://10.11.0.148:808";' >> apt.conf

 



# 使用apt-get update -y 经常报错如下,并且下载老是在98%的时候暂停,一直如此,可能是nginx依赖的容器底层的debian系统太老,更换nginx版本为最新

E: Some index files failed to download. They have been ignored, or old ones used instead
rm /var/lib/apt/lists/* -vrf

你可能感兴趣的:(docker容器内部设置apt源和网络代理)