vpncloud.blog · 2026 中文机场评测、每 GB 透明计算与全平台客户端教程 更新日期:2026-12-02 · 14 家品牌 · 30 篇教程 · 100 篇文章
快速结论

Docker 拉取镜像是由后台 Docker Daemon 进程发起的,不会自动读取终端环境变量。Docker Desktop 可在 Settings → Resources → Proxies 直接填写 `http://127.0.0.1:7897`;Linux 服务器则需修改 `/etc/systemd/system/docker.service.d/http-proxy.conf`。

详细配置步骤

1. Windows / macOS Docker Desktop 设置

打开 Docker Desktop → Settings → Resources → Proxies → 打开 Manual proxy configuration,在 Web Server (HTTP/HTTPS) 填入 `http://127.0.0.1:7897` 并点击 Apply & restart。

2. Linux Docker Engine Daemon 配置

创建 `/etc/systemd/system/docker.service.d/http-proxy.conf`,在 `[Service]` 下添加 `Environment="HTTP_PROXY=http://127.0.0.1:7890" "HTTPS_PROXY=http://127.0.0.1:7890" "NO_PROXY=localhost,127.0.0.1"`。

3. 重载 systemd 并重启 Docker

运行 `sudo systemctl daemon-reload && sudo systemctl restart docker`,用 `docker info | grep -i proxy` 验证生效。

4. 构建容器时传入代理参数(可选)

在 `docker build` 内部安装海外包时,可通过 `--build-arg HTTPS_PROXY=http://host.docker.internal:7897` 让容器内临时访问宿主机代理(需客户端开启 Allow LAN)。

常见问题与排错技巧

  • 拉取大型镜像(数 GB)时建议留意机场剩余流量,国内镜像源或内网仓库地址记得写入 `NO_PROXY`。

相关知识百科