阿东的笔记_  工具
## 使用Docker网络慢,配置代理加速 #### 一:临时设置 - windows ``` Shell $Env:http_proxy="http://127.0.0.1:7890";$Env:https_proxy="http://127.0.0.1:7890" ``` - linux/mac ``` Bash export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 ``` #### 二:Docker Daemon 拉取或推送镜像 - linux ``` Bash # 目录 sudo mkdir -p /etc/systemd/system/docker.service.d # 写入内容 vim /etc/systemd/system/docker.service.d/http-proxy.conf ``` http-proxy.conf ``` ini [Service] Environment="HTTP_PROXY=http://127.0.0.1:7890/" Environment="HTTPS_PROXY=http://127.0.0.1:7890/" Environment="NO_PROXY=localhost,127.0.0.1" ``` #### 三:Container 使用代理 vim ~/.docker/config.json ``` json { "proxies": { "default": { "httpProxy": "http://127.0.0.1:7890", "httpsProxy": "http://127.0.0.1:7890", "noProxy": "*.test.example.com,.example2.com,127.0.0.0/8" } } } ``` #### windows 1. 打开 docker desktop 设置 -> Resources -> Proxies -> 打开 Manual proxy 配置 2. 填写代理地址:127.0.0.1:7890 3. 保存 (Apply & restart) [![demo](https://static.adong.wiki/static/images/md/20241018152139.png)](https://static.adong.wiki/static/images/md/20241018152139.png)
adddge@sohu.com  | 桂ICP备2022009838号-2