1 2 | sudo mkdir -p /etc/docker sudo vim /etc/docker/daemon.json |
daemon.json配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | { "registry-mirrors": [ "https://dockerhub.azk8s.cn", "https://docker.mirrors.ustc.edu.cn", "http://hub-mirror.c.163.com", "https://k8s.gcr.io", "https://github-releases.githubusercontent.com", "https://ustc-edu-cn.mirror.aliyuncs.com" ], "insecure-registries": [ "registry.me:5000", "http://docker.mirrors.ustc.edu.cn", "https://k8s.gcr.io", "https://github-releases.githubusercontent.com", "https://registry-1.docker.io", "decs.com" ], "exec-opts": [ "native.cgroupdriver=systemd" ] } |
1 2 | sudo mkdir -p /etc/systemd/system/docker.service.d sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf |
http-proxy.conf配置模板如下(谨慎配置,确保代理设置正确):
1 2 3 4 | [Service] Environment="HTTP_PROXY=http://proxy.example.com:8080" Environment="HTTPS_PROXY=http://proxy.example.com:8080" Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com" |
1 2 | sudo systemctl daemon-reload sudo systemctl restart docker |