1.pip
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
2.docker
sudo mkdir /etc/docker/
sudo touch /etc/docker/daemon.json
sudo vim /etc/docker/daemon.json
# 添加下面代码
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn/",
"https://hub-mirror.c.163.com",
"https://registry.docker-cn.com",
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com",
"https://registry.docker-cn.com"
]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
3.docker添加用户组
sudo groupadd docker
sudo gpasswd -a kang docker
sudo reboot
#检查是否添加到组
cat /etc/group
4.配置apt国内源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakcup
sudo vim /etc/apt/sources.list
# 添加下面代码:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# 更新源
sudo apt update
5.Dockerfile中一些包的国内源配置
apt-替换
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
alpine的apk-添加
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
proxy
ENV http_proxy=http://c-prc.xxx.com:913
ENV https_proxy=http://c-prc.xxx.com:913
go-替换
wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
goproxy-添加
ENV GO111MODULE on
ENV GOPROXY "https://goproxy.cn"
pip-添加
RUN mkdir -p ~/.pip && \
printf '[global]\n\ttrusted-host=mirrors.aliyun.com\n\tindex-url=http://mirrors.aliyun.com/pypi/simple' > ~/.pip/pip.conf
Miniconda替换
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
RUN wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
github替换为gitee(网址)
python-etcd3-替换
RUN git clone https://github.com/kragniz/python-etcd3 && \
RUN git clone https://gitee.com/mirrors/python-etcd3.git && \
InfluxDB-替换
git clone https://github.com/influxdata/influxdb ${INFLUXDB_GO_PATH} && \
git clone https://gitee.com/mirrors/InfluxDB.git ${INFLUXDB_GO_PATH} && \
etcd-替换
git clone https://github.com/etcd-io/etcd ${ETCD_GO_PATH} && \
git clone https://gitee.com/mirrors/etcd.git ${ETCD_GO_PATH} && \
6.github资源下载加速
github上的资源下载缓慢,经常中断,搭建海外服务器又费用不菲,为此让我很苦恼,一直在尝试国内下载好用的方式。今天终于找到了。这个网站提供了GitHub文件、Releases、archive以及raw.githubusercontent.com文件加速下载服务。来,网址奉上:https://ghproxy.com/
具体使用方法:
做个一个测试,在clone代码仓库的时候,使用原来的方式大概23k/s,添加了加速以后1M/s,速度相当快。