docker 配置

1.镜像加速

配置阿里云镜像加速地址:

1.1 进入管理控制台获取镜像加速器地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors  找到私有的加速器地址

1.2 对于Docker Desktop,在Settings--Docker Engine中编辑窗口内的JSON串,填写加速器地址

1.3 对于docker, 修改daemon.json,填写加速器地址

例如:

{
    "registry-mirrors": [
        "https://s1gkcmwb.mirror.aliyuncs.com"
    ]
}

2.docker 拉取代理配置

sudo mkdir -p /etc/systemd/system/docker.service.d

sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80"
Environment="HTTPS_PROXY=https://proxy.example.com:443"
Environment="NO_PROXY=your-registry.com,10.10.10.10,*.example.com"


sudo systemctl daemon-reload
sudo systemctl restart docker

 

 

3. docker build 代理

 docker build . \
    --build-arg "HTTP_PROXY=http://127.0.0.1:10809/" \
    --build-arg "HTTPS_PROXY=http://127.0.0.1:10809/" \
    --build-arg "NO_PROXY=localhost,127.0.0.1" \
    --network host      -t your/image:tag

 

 

4. containerd

#containerd

  vim /etc/systemd/system/containerd.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://192.168.222.1:6790"
Environment="HTTPS_PROXY=http://192.168.222.1:6790"
Environment="NO_PROXY=localhost,127.0.0.1,.cluster.local,.svc,sealos.hub,10.96.0.0/12,10.93.98.0/24,10.244.0.0/16,192.168.0.0/12"