---
title: NAS Docker 代理配置笔记
source:
author: shenwei
published:
created:
description:
tags: []
---

# NAS Docker 代理配置笔记

## Synology NAS Docker 代理配置

### 1. 代理配置文件位置

```
/etc/systemd/system/pkg-ContainerManager-dockerd.service.d/http-proxy.conf
```

### 2. 原始配置内容

```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"
```

### 3. 注释代理的方法

```bash
# 注释掉 HTTP_PROXY 和 HTTPS_PROXY
sudo sed -i 's/^Environment="HTTP_PROXY/#Environment="HTTP_PROXY/' /etc/systemd/system/pkg-ContainerManager-dockerd.service.d/http-proxy.conf
sudo sed -i 's/^Environment="HTTPS_PROXY/#Environment="HTTPS_PROXY/' /etc/systemd/system/pkg-ContainerManager-dockerd.service.d/http-proxy.conf
```

### 4. 重启 Docker 服务

```bash
# 重载 systemd 配置
sudo systemctl daemon-reload

# 重启 container-manager (Docker)
sudo systemctl restart pkg-ContainerManager-dockerd

# 查看服务状态
sudo systemctl status pkg-ContainerManager-dockerd
```

### 5. 相关命令

| 操作 | 命令 |
|------|------|
| 查看当前代理配置 | `sudo cat /etc/systemd/system/pkg-ContainerManager-dockerd.service.d/http-proxy.conf` |
| 启用代理 | 取消注释 (去掉 #) |
| 禁用代理 | 注释掉 (添加 #) |
| 重启 Docker | `sudo systemctl restart pkg-ContainerManager-dockerd` |

### 6. 注意事项

- 这是 Synology NAS 特有的路径，普通 Linux 系统通常在 `/etc/systemd/system/docker.service.d/`
- 修改后必须 `systemctl daemon-reload` 才能生效
- Docker 拉取镜像时会使用此代理配置

---

*最后更新: 2026-03-27*