Appearance
快速开始
使用 Docker Compose(推荐)
网络模式
必须使用 host 网络模式,ARP 等工具才能正常工作。 使用 host 模式后无需映射端口,直接访问宿主机 12376 端口。
yaml
services:
netdiagnose:
image: ccr.ccs.tencentyun.com/liumou/netdiagnose:latest
container_name: netdiagnose
network_mode: host
environment:
- TZ=Asia/Shanghai
- SERVER_HOST=0.0.0.0
- SERVER_PORT=12376
- JWT_SECRET=change-this-to-a-secure-random-string
- DB_PATH=/data/netdiagnose.db
- LOG_CONSOLE_LEVEL=info
- DNS_SERVERS=119.29.29.29,223.5.5.5
cap_add:
- NET_RAW
- NET_ADMIN
security_opt:
- no-new-privileges:false
volumes:
- ./data:/data
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:12376/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
restart: unless-stopped启动服务:
bash
docker compose up -d打开浏览器访问 http://宿主机IP:12376。
使用 Docker Run
如果不使用 Docker Compose,也可以直接通过 docker run 部署。
网络模式
必须使用 host 网络模式(--network host),ARP 等工具才能正常工作。 使用 host 模式后无需映射端口,直接访问宿主机 12376 端口。
最简启动
bash
docker run -d \
--name netdiagnose \
--network host \
--cap-add=NET_RAW --cap-add=NET_ADMIN \
-e JWT_SECRET=change-this-to-a-secure-random-string \
-v ./data:/data \
ccr.ccs.tencentyun.com/liumou/netdiagnose:latest完整启动(推荐)
包含全部环境变量、数据持久化、健康检查和自动重启:
bash
docker run -d \
--name netdiagnose \
--network host \
--cap-add=NET_RAW --cap-add=NET_ADMIN \
--security-opt no-new-privileges=false \
-e TZ=Asia/Shanghai \
-e SERVER_HOST=0.0.0.0 \
-e SERVER_PORT=12376 \
-e JWT_SECRET=change-this-to-a-secure-random-string \
-e DB_PATH=/data/netdiagnose.db \
-e LOG_CONSOLE_LEVEL=info \
-e PING_MAX_COUNT=200 \
-e TCPING_MAX_COUNT=200 \
-e MTR_MAX_COUNT=100 \
-e DNS_SERVERS=119.29.29.29,223.5.5.5 \
-v ./data:/data \
--health-cmd="wget --no-verbose --tries=1 --spider http://localhost:12376/health || exit 1" \
--health-interval=30s \
--health-timeout=10s \
--health-retries=3 \
--health-start-period=10s \
--restart=unless-stopped \
ccr.ccs.tencentyun.com/liumou/netdiagnose:latest参数说明
| 参数 | 说明 |
|---|---|
--name netdiagnose | 容器名称 |
--network host | 使用宿主机网络(必须,ARP 等工具依赖此模式) |
--cap-add=NET_RAW | 添加原始套接字权限(ping / traceroute / nmap 等需要) |
--cap-add=NET_ADMIN | 添加网络管理权限(MTR / ARP 等需要) |
--security-opt no-new-privileges=false | 允许容器内提权以设置 capability |
-e TZ=Asia/Shanghai | 时区 |
-e JWT_SECRET=... | JWT 签名密钥,生产环境务必修改 |
-e DB_PATH=/data/netdiagnose.db | 数据库文件路径 |
-v ./data:/data | 数据持久化目录映射 |
--health-* | 健康检查配置 |
--restart=unless-stopped | 容器异常退出自动重启 |
数据目录权限
容器以 UID 888(appuser)运行,需确保宿主机 ./data 目录属主为 888:888:
bash
mkdir -p ./data && chown 888:888 ./data若不手动设置属主,容器启动时会自动尝试修正 /data 目录权限。
JWT_SECRET
默认密钥 netdiagnose-secret-key-change-me 仅适用于测试环境。生产环境请务必通过 -e JWT_SECRET=<你的随机字符串> 设置一个足够复杂的密钥。
常用运维命令
bash
# 查看容器状态
docker ps --filter name=netdiagnose
# 查看实时日志
docker logs -f netdiagnose
# 查看最近 200 行日志
docker logs --tail 200 netdiagnose
# 重启容器
docker restart netdiagnose
# 停止并删除容器(数据保留在 ./data 目录)
docker stop netdiagnose && docker rm netdiagnose
# 更新镜像
docker pull ccr.ccs.tencentyun.com/liumou/netdiagnose:latest
docker stop netdiagnose && docker rm netdiagnose
# 然后重新执行 docker run 命令打开浏览器访问 http://宿主机IP:12376。
首次登录
- 打开
http://localhost:12376 - 使用默认凭据登录:
admin/admin123 - 建议登录后立即修改密码