Files
nexus/wiki/concepts/Docker-Daemon-Proxy.md
2026-04-27 16:26:34 +08:00

70 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Docker Daemon Proxy"
type: concept
tags: [docker, proxy, systemd, container]
date: 2026-05-14
---
# Docker Daemon Proxy
## Aliases
- Docker Daemon Proxy
- Docker 守护进程代理
- Dockerd Proxy
- HTTP_PROXY for Docker Daemon
- Docker Daemon HTTP 代理
## Definition
Docker Daemon Proxy 是指通过 systemd 环境变量(`HTTP_PROXY`/`HTTPS_PROXY`)为 Docker 守护进程(`dockerd`)配置显式代理,使所有 `docker pull``docker build` 和容器出站流量走指定代理服务器。这是透明代理失效时(尤其在群晖 DSM/Ubuntu Server 环境中)的推荐替代方案。
## When to Use
- 透明代理V2RayA/Clash对 Docker Daemon 网络栈无效
- 需要可靠、可预测的 `docker pull` 代理行为
- 生产环境/多容器部署中需要与系统路由表解耦
- 群晖 DSM 7.x服务名 `pkg-ContainerManager-dockerd`
## Implementation Pattern
### Step 1: Create systemd override directory
```bash
sudo mkdir -p /etc/systemd/system/pkg-ContainerManager-dockerd.service.d/
```
### Step 2: Create proxy config file
```bash
sudo vi /etc/systemd/system/pkg-ContainerManager-dockerd.service.d/http-proxy.conf
```
### Step 3: Write environment variables
```ini
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:20171"
Environment="HTTPS_PROXY=http://127.0.0.1:20171"
Environment="NO_PROXY=localhost,127.0.0.1,192.168.*,*.synology.me"
```
### Step 4: Reload and restart
```bash
sudo systemctl daemon-reload
sudo systemctl restart pkg-ContainerManager-dockerd
```
## Key Distinction from Transparent Proxy
| 维度 | 透明代理Transparent Proxy | Docker Daemon Proxy |
|------|------------------------------|-------------------|
| 作用层级 | iptables内核网络层 | systemd 环境变量 |
| 生效范围 | 所有出站流量NAS 本机) | 仅 Docker Daemon 进程 |
| DSM 兼容性 | 可能失效(网络栈差异) | 稳定可靠 |
| 对其他服务的影响 | 可能影响 NAS 其他网络服务 | 仅影响 Docker |
| 维护难度 | 高(修改系统路由表) | 低(配置分离) |
## Related Sources
- [[群晖NAS科学上网方法]] — DSM 7.x 环境下的 Docker Daemon Proxy 完整配置
- [[Ubuntu-Server科学上网]] — Ubuntu Server 环境下的 Docker Daemon Proxy 配置
## Related Concepts
- [[透明代理]] — V2RayA 的默认透明代理机制(在 DSM 中对 Docker Daemon 失效)
- [[V2RayA]] — Docker Daemon Proxy 的上游代理服务提供者
- [[分流模式]] — V2RayA 的流量路由策略
- [[iptables]] — 透明代理依赖的内核规则