Docker配置指导
- 创建daemon.json文件配置Docker。
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" ] }
- 创建http-proxy.conf文件配置代理。若已配置代理,可跳过此步骤。
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"
- proxy.example.com:替换为实际代理服务器地址。
- NO_PROXY:配置不需要代理的地址。
- 重启Docker服务。
1 2
sudo systemctl daemon-reload sudo systemctl restart docker
父主题: 参考