Deluge 2.2.0 Docker Compose 部署指南
以 Docker Compose 部署 Deluge 2.2.0 双服务栈(deluged + deluge-web),覆盖镜像选型、端口与子网规划、首启改密与添加种子下载验证,全程实测回显。
Deluge 2.2.0 Docker Compose 部署指南
目标:在 Linux 服务器上以 Docker Compose 方式部署 Deluge 2.2.0(deluged 守护进程 + deluge-web 双服务单栈),完成首次启动、默认密码修改与添加种子下载验证。已在 Ubuntu 22.04(x86_64)主机上实测通过,Deluge 版本 2.2.0(镜像内置 deluged/deluge-web/deluge-console 均 2.2.0,libtorrent 2.0.13.0)。
一、环境信息
- 操作系统:Ubuntu 22.04(x86_64,内核 5.15+)
- 软件版本:Deluge 2.2.0(官方最新稳定版,发布于 2025-04-28,来源官方 Changelog,查询日期 2026-10-30)、libtorrent 2.0.13.0
- 容器化发行版:linuxserver/deluge(社区标准镜像,内置 deluged + deluge-web 双服务,由 s6-overlay 托管进程)
- 端口规划:Web UI 8112 → 宿主 8149;守护进程 RPC 58846 → 宿主 8152;BT 入站 6881 → 宿主 8155
- 数据目录:
/opt/deluge/config(配置)、/opt/deluge/downloads(下载) - 独立网络:自定义 bridge 子网
10.89.56.0/24
二、镜像选型说明
| 候选 | 说明 | 结论 |
|---|---|---|
lscr.io/linuxserver/deluge:latest | LinuxServer.io 官方发布通道,s6 托管 deluged + deluge-web 双服务 | 首选 |
docker.1ms.run/linuxserver/deluge:latest | linuxserver/deluge 的国内镜像加速通道,内容一致 | 网络受限时可用 |
| 源码自装(pip install deluge) | 依赖系统 libtorrent/GTK3 编译环境 | 本篇不展开 |
⚠️ 网络说明:本次实测环境中
lscr.io官方通道拉取长时间无进展(fs layer 卡住),改走国内镜像加速源docker.1ms.run/linuxserver/deluge:latest成功拉取(digest1dbf9663387f,326MB)。当前实测可用渠道为 docker.1ms.run;网络可达时可直接使用官方通道lscr.io/linuxserver/deluge:latest,二者仅仓库前缀不同。
镜像内三件套版本实测(进入镜像执行 deluged --version 等,实测回显):
deluged 2.2.0
libtorrent: 2.0.13.0
Python: 3.12.15
OS: Linux 7.0.0-38-generic
deluge-web 2.2.0
libtorrent: 2.0.13.0
Python: 3.12.15
deluge-console 2.2.0
libtorrent: 2.0.13.0
Python: 3.12.15
与官方最新稳定版 2.2.0 一致(官方 Changelog 实查 2.2.0 发布于 2025-04-28,查询日期 2026-10-30),镜像选型定版。
三、前置条件
3.1 宿主端口实查
选取宿主端口前先用 ss 确认目标端口空闲(实测回显,仅列端口号):
ss -ltn | awk 'NR>1{print $4}' | grep -oE '[0-9]+$' | sort -un
22 53 631 1935 8147 8554 8888 8889 8892 38443 40051 40973
实测确认 8149、8152、8155 未被占用,可分别用作 Web UI、守护进程 RPC、BT 入站端口的宿主映射。若你的机器上这些端口已被占用,按同样方法另选空闲端口即可。
3.2 网络子网实查
查看现有 Docker 网络与已占子网(实测回显):
docker network ls --format '{{.Name}}'
bridge
host
none
本次环境中无自定义网络,从 10.89.0.0/16 空闲段选取 56 号槽显式划分子网 10.89.56.0/24(若已有网络占用该段,docker network ls -q | xargs -n1 docker network inspect --format '{{.Name}} {{range .IPAM.Config}}{{.Subnet}}{{end}}' 实查后换空闲槽位)。
3.3 目录准备
mkdir -p /opt/deluge/config /opt/deluge/downloads
四、部署步骤
4.1 Compose 编排文件
在 /opt/deluge/compose/docker-compose.yml 写入以下内容(完整文件,实测采用):
name: deluge-2.2.0-stack
services:
deluge:
image: docker.1ms.run/linuxserver/deluge:latest
container_name: deluge-2.2.0-app
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
- DELUGE_LOGLEVEL=info
volumes:
- /opt/deluge/config:/config
- /opt/deluge/downloads:/downloads
ports:
- "8149:8112"
- "8152:58846"
- "8155:6881"
- "8155:6881/udp"
networks:
deluge-net:
restart: unless-stopped
networks:
deluge-net:
name: deluge-2.2.0-net
driver: bridge
ipam:
config:
- subnet: 10.89.56.0/24
要点解读:
name: deluge-2.2.0-stack:显式声明 Compose 项目名,避免与主机上其他 compose 栈同名互相干扰。container_name: deluge-2.2.0-app:容器名带版本号,便于docker logs/exec时辨识。- 端口三组映射:8112(Web UI)、58846(deluged RPC)、6881(BT 入站,TCP+UDP 双协议都要映射)。
restart: unless-stopped:进程崩溃或主机重启后自动拉起。- 网络显式指定子网与网络名,不依赖 Docker 自动分配。
4.2 拉起栈并验证
cd /opt/deluge/compose
docker compose up -d
实测回显:
Network deluge-2.2.0-net Created
Container deluge-2.2.0-app Creating
Container deluge-2.2.0-app Created
Container deluge-2.2.0-app Starting
Container deluge-2.2.0-app Started
验证监听与状态(实测回显):
docker ps --format '{{.Names}}\t{{.Status}}\t{{.Ports}}'
deluge-2.2.0-app Up 8 seconds 58946/tcp, 58946/udp, 0.0.0.0:8155->6881/tcp, 0.0.0.0:8155->6881/udp, [::]:8155->6881/tcp, [::]:8155->6881/udp, 0.0.0.0:8149->8112/tcp, [::]:8149->8112/tcp, 0.0.0.0:8152->58846/tcp, [::]:8152->58846/tcp
curl -s -o /dev/null -w 'HTTP %{http_code}\n' http://127.0.0.1:8149/
HTTP 200
Web 端口返回 200 即部署成功,浏览器访问 http://<服务器IP>:8149/ 进入 Web UI。
4.3 首次启动日志判读
docker logs deluge-2.2.0-app
输出节选(实测首尾):
15:05:21 [INFO ][deluge.core.authmanager :1672] Successfully loaded auth: /config/auth
15:05:21 [INFO ][deluge.core.torrentmanager :1672] Finished loading 0 torrents in 0:00:00.000374
Connection to 127.0.0.1 58846 port [tcp/*] succeeded!
15:05:22 [INFO ][deluge.ui.ui:68 ] Deluge ui 2.2.0
15:05:22 [INFO ][deluge.ui.ui:70 ] Starting web ui..
15:05:22 [WARNING ][deluge.config :401 ] Unable to open config file /config/web.conf: [Errno 2] No such file or directory: '/config/web.conf'
15:05:22 [INFO ][deluge.ui.web.server :1672] Starting webui server at PID 191
15:05:22 [INFO ][deluge.ui.web.server :1672] Serving at http://0.0.0.0:8112/
Connection to 127.0.0.1 8112 port [tcp/*] succeeded!
[ls.io-init] done.
15:05:23 [INFO ][deluge.core.torrentmanager :1672] on_alert_external_ip: 182.54.113.29
判读要点:
Successfully loaded auth: /config/auth:守护进程 RPC 认证文件就绪。Serving at http://0.0.0.0:8112/+[ls.io-init] done.:deluge-web 就绪。- 首启时
web.conf、hostlist.conf不存在属正常(deluge-web 首次运行时自动生成),对应 WARNING 无需处理。 on_alert_external_ip显示守护进程已探测到公网出口 IP,BT 网络连通正常。
五、数据持久化说明
| 宿主路径 | 容器内路径 | 内容 |
|---|---|---|
| /opt/deluge/config | /config | auth(RPC 账号)、core.conf(核心配置)、web.conf(Web UI 配置)、hostlist.conf(连接管理)、deluged.pid、plugins/(插件)、ssl/(证书)、state/(任务状态与 fastresume)、torrents/(种子文件副本) |
| /opt/deluge/downloads | /downloads | 下载完成与进行中的数据文件(core.conf 的 download_location 默认指向此处) |
首启后实测的配置目录清单(实测回显):
-rw------- 1 yahui yahui 56 Oct 30 15:05 auth
-rw-r--r-- 1 yahui yahui 2744 Oct 30 15:05 core.conf
-rw------- 1 yahui yahui 252 Oct 30 15:05 hostlist.conf
-rw------- 1 yahui yahui 962 Oct 30 15:06 web.conf
drwxr-xr-x 2 yahui yahui 4096 Oct 30 15:05 plugins
drwxr-xr-x 2 yahui yahui 4096 Oct 30 15:05 ssl
drwxr-xr-x 2 yahui yahui 4096 Oct 30 15:05 state
drwxr-xr-x 2 yahui yahui 4096 Oct 30 15:05 torrents
⚠️ 注意:
PUID=1000/PGID=1000时,/config与/downloads内文件属主为宿主 UID 1000 的用户。备份/迁移时直接打包这两个目录即可完整保留任务状态。
六、环境变量表
| 变量 | 实测值 | 说明 |
|---|---|---|
| PUID | 1000 | 容器内进程运行用户 UID,决定 /config、/downloads 文件属主 |
| PGID | 1000 | 容器内进程运行组 GID |
| TZ | Asia/Shanghai | 时区,影响日志时间戳与 Scheduler 插件时段判断 |
| DELUGE_LOGLEVEL | info | deluged 日志级别,可选 error/warning/info/debug |
七、首次登录与改密验证
7.1 默认密码登录
deluge-web 首次启用时默认密码为 deluge(无用户名输入框,仅密码)。用浏览器进入 http://<服务器IP>:8149/ 输入 deluge 即可登录。
等价的 API 验证方式(实测回显):
curl -s -c cookies.txt -H 'Content-Type: application/json' \
-d '{"method":"auth.login","params":["deluge"],"id":1}' http://127.0.0.1:8149/json
{"result": true, "error": null, "id": 1}
返回 result: true 并下发 _session_id 会话 Cookie,登录成功。
7.2 修改管理密码
登录后按 Web UI 提示(首次登录会弹出改密界面,对应 web.conf 的 first_login: true)将密码改为强口令;本环境按示例账号规范改为 q1w2e3r4(生产环境请使用更强的私有口令)。等价的 API 改密方式(实测回显):
curl -s -b cookies.txt -H 'Content-Type: application/json' \
-d '{"method":"auth.change_password","params":["deluge","q1w2e3r4"],"id":2}' \
http://127.0.0.1:8149/json
{"result": true, "error": null, "id": 2}
新密码复验(实测回显):
curl -s -c cookies2.txt -H 'Content-Type: application/json' \
-d '{"method":"auth.login","params":["q1w2e3r4"],"id":3}' http://127.0.0.1:8149/json
{"result": true, "error": null, "id": 3}
改密后落盘的 web.conf(实测节选):密码以盐值 + SHA1 摘要存储,不落明文;内部登录名固定为 admin:
"first_login": true,
"pwd_salt": "7278339d7d9163731466d8d78acca6a7649985ee",
"pwd_sha1": "4923dd760b1592f172f7775040b55558365b710e",
"session_timeout": 3600,
"sessions": {
"705eb915...": { "expires": 1793347565.0, "level": 10, "login": "admin" },
...
},
"show_session_speed": false,
"theme": "gray"
八、添加种子下载验证
8.1 准备种子文件
以 Debian 官方发布的网络安装镜像种子为例(合法公开测试种子),直接在下载目录获取:
curl -s -m 30 -L -o /opt/deluge/downloads/debian-13.7.0-amd64-netinst.iso.torrent \
"https://cdimage.debian.org/debian-cd/current/amd64/bt-cd/debian-13.7.0-amd64-netinst.iso.torrent"
ls -la /opt/deluge/downloads/
-rw-r--r-- 1 root root 60948 Oct 30 15:07 debian-13.7.0-amd64-netinst.iso.torrent
8.2 经 Web UI 添加
浏览器登录 Web UI → 左上「Add」→ 选择文件 /opt/deluge/downloads/debian-13.7.0-amd64-netinst.iso.torrent → Add。等价的 API 方式(需先登录并连接守护进程,实测回显):
curl -s -b cookies2.txt -H 'Content-Type: application/json' \
-d '{"method":"web.add_torrents","params":[[{"path":"/downloads/debian-13.7.0-amd64-netinst.iso.torrent","options":{}}]],"id":8}' \
http://127.0.0.1:8149/json
{"result": [[true, "7acf8fb590b2060dd9c3146ef770169d593433b0"]], "error": null, "id": 8}
返回的 7acf8fb5... 即该种子的任务 ID(infohash)。
⚠️ 注意:
path参数必须传 Web 服务侧可见的真实文件路径或磁力链,不能传文件内容的 base64 字符串——实测直接传 base64 会报OSError: [Errno 36] Filename too long(Deluge 把内容串当文件名打开了)。另外若会话尚未连接守护进程,会报AttributeError: 'NoneType' object has no attribute 'call',需先调用web.get_hosts→web.connect(<host_id>)(host_id 取自web.get_hosts返回,实测为守护进程连接管理里的条目)。
8.3 下载进度验证
查询任务状态(实测回显,两次采样间隔 25 秒):
curl -s -b cookies2.txt -H 'Content-Type: application/json' \
-d '{"method":"web.get_torrent_status","params":["7acf8fb590b2060dd9c3146ef770169d593433b0",["name","state","progress","total_size","download_payload_rate","num_seeds","num_peers","eta","save_path"]],"id":10}' \
http://127.0.0.1:8149/json
{"result": {"state": "Downloading", "download_payload_rate": 15523945, "num_peers": 6, "num_seeds": 79, "progress": 34.558902740478516, "save_path": "/downloads", "total_size": 792723456, "eta": 33, "name": "debian-13.7.0-amd64-netinst.iso"}, "error": null, "id": 10}
{"result": {"state": "Downloading", "download_payload_rate": 15702594, "num_peers": 5, "num_seeds": 156, "progress": 90.20539855957031, "name": "debian-13.7.0-amd64-netinst.iso"}, "error": null, "id": 11}
实测下载速率约 15 MB/s、连接 156 个做种节点,进度从 34.6% 增长到 90.2%,网络与磁盘链路全部正常。约 40 秒后任务完成(实测回显):
{"result": {"state": "Seeding", "num_seeds": 0, "progress": 100.0, "download_location": "/downloads", "total_done": 792723456, "name": "debian-13.7.0-amd64-netinst.iso"}, "error": null, "id": 12}
落盘文件与种子元数据字节数精确一致(实测回显):
-rw-r--r-- 1 yahui yahui 792723456 Oct 30 15:09 debian-13.7.0-amd64-netinst.iso
至此部署、认证、下载全链路验证完成。
九、等价 docker run 命令
不用 Compose 时,以下 docker run 命令与上述编排等价:
docker network create --subnet 10.89.56.0/24 deluge-2.2.0-net
docker run -d \
--name deluge-2.2.0-app \
--network deluge-2.2.0-net \
-p 8149:8112 -p 8152:58846 -p 8155:6881 -p 8155:6881/udp \
-e PUID=1000 -e PGID=1000 -e TZ=Asia/Shanghai -e DELUGE_LOGLEVEL=info \
-v /opt/deluge/config:/config \
-v /opt/deluge/downloads:/downloads \
--restart unless-stopped \
docker.1ms.run/linuxserver/deluge:latest
长跑环境仍建议用 Compose 编排,便于以项目为单位统一升级与清理。
十、常用运维命令
docker compose ps # 栈内服务状态
docker compose logs -f --tail 100 # 滚动查看日志
docker compose restart # 重启栈
docker compose down # 停止并删除栈(数据目录保留)
docker compose pull && docker compose up -d # 升级镜像(/config 状态自动保留)
十一、常见问题
Q1:访问 Web UI 一直要求登录但 deluge 密码无效?
deluge-web 的密码存于 /config/web.conf(pwd_salt/pwd_sha1)。忘记密码时可停栈后删除 web.conf 再 up -d,重新恢复默认密码 deluge;RPC 侧账号存于 /config/auth(localclient 随机口令,首次生成),与 Web UI 密码是两套体系。
Q2:web.add_torrents 报 Filename too long?
path 传了文件内容 base64 串。改传服务器侧真实路径(如 /downloads/xxx.torrent)或磁力链(magnet:?xt=...)。
Q3:web.add_torrents 报 'NoneType' object has no attribute 'call'?
会话未连接守护进程。先 web.get_hosts 取 host_id,再 web.connect 该 host_id,之后重试。
Q4:BT 下载无速度?
依次检查:6881 端口(TCP+UDP)是否放行并映射(docker ps 的 Ports 列确认);core.conf 中 upnp/natpmp 是否开启;Web UI 连接图标是否提示端口不可达。内网环境至少保证 DHT 可用(status 输出 DHT Nodes > 0)。
Q5:升级后任务丢失?
任务状态存于 /config/state/(torrents.state + torrents.fastresume),只要 /config 目录挂载未变,docker compose pull && up -d 升级不丢任务;不要删除 /config。
十二、参考链接
- Deluge 官方文档站:https://deluge.readthedocs.io/
- 官方 Changelog(2.2.0):https://deluge.readthedocs.io/en/latest/changelog.html
- linuxserver/deluge 镜像文档:https://docs.linuxserver.io/images/deluge/
- Deluge 官网:https://deluge-torrent.org/