
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
自动更新 DNS 解析 到本机 IP 地址,支持 IPv4 和 IPv6,本地(内网)IP 和公网 IP。
Automatically update DNS records to your current IP address. Supports IPv4/IPv6, local (LAN) and public IP.
https://img.shields.io/github/v/release/NewFuture/DDNS?&logo=github&style=flatten](https://github.com/NewFuture/DDNS/releases/latest) https://img.shields.io/pypi/v/ddns.svg?label=ddns&logo=pypi&style=flatten](https://pypi.org/project/ddns/) https://img.shields.io/docker/v/newfuture/ddns?label=newfuture/ddns&logo=docker&&sort=semver&style=flatten](https://hub.docker.com/r/newfuture/ddns) https://github.com/NewFuture/DDNS/actions/workflows/build.yml/badge.svg?event=push](https://github.com/NewFuture/DDNS/actions/workflows/build.yml) https://github.com/NewFuture/DDNS/actions/workflows/publish.yml/badge.svg](https://github.com/NewFuture/DDNS/actions/workflows/publish.yml)
Features:
- Docker compatible, cross-platform, lightweight image (<7MB), multi-arch support
- Built-in scheduler (auto update every 5 min)
- No external dependencies, optimized performance, low resource usage
- Multiple configuration methods: CLI, JSON file, environment variables
DDNS 镜像版本(Docker Tag):
latest: 最新稳定版(Default stable release )next: 下一个版本(Next beta version)edge 最新开发版,不稳定(Latest dev build, unstable, master branch)bashdocker pull newfuture/ddns:latest docker pull newfuture/ddns
您也可以指定特定版本,例如:
bashdocker pull newfuture/ddns:v4.0.0
镜像会同步发布到以下源:
docker.io/newfuture/ddnsghcr.io/newfuture/ddnssupports docker pull ghcr.io/newfuture/ddns
DDNS Docker 镜像支持三种配置方式:命令行,环境变量和配置文件。
DDNS Docker image supports three configuration methods: command line, environment variables, and config file.
- If command line arguments are set, the container runs DDNS directly (no scheduler).
- See CLI docs for details.
- This mode is suitable for one-time runs or debugging.
- For scheduled updates, use environment variables or config file.
- See Environment Variable Docs for all supported variables.
- Mount your local config directory to
/ddns/in the container. See JSON Config Docs for details.
注意 (docker run 时的注意事项):
-v 挂载配置文件或目录,确保容器内的 /ddns/ 目录包含有效的配置文件(如 config.json),否则 DDNS 将无法正常工作。--network host,请确保您的 Docker 守护进程已正确配置以支持此模式。-d 参数可以让容器在后台运行, 使用前请确保您了解 Docker 的基本操作。-e DDNS_XXX=YYY 参数可以设置环境变量,容器内的 DDNS 程序会自动读取这些变量。可以参考命令行参数说明获取详细的参数列表。
此时 docker run -v /local/config/:/ddns/ --name=ddns --network=host newfuture/ddns 就相当于 ddns 命令行,不会执行定时任务。
此方式适合需要一次性运行或调试的场景, 参数与 DDNS 命令行参数一致。
bash# 等价于 ddns -h docker run --rm newfuture/ddns -h # 加上 --debug 参数可以启用调试模式(或者 --log.level=debug) docker run --rm -v /local/config/:/ddns/ --network=host newfuture/ddns --dns=dnspod --id=12345 --token=mytokenkey --ipv4=www.example.com --ipv4=ipv4.example.com --index4 public --index4 0 --debug
环境变量和命令行参数类似, 加上 DDNS 前缀,推荐全大写。数组类型需要使用 JSON 格式或者单引号包裹。
当然也可以使用 --env-file 参数来加载环境变量文件。
bashdocker run -d \ -e DDNS_DNS=dnspod \ -e DDNS_ID=12345 \ -e DDNS_TOKEN=mytokenkey \ -e DDNS_IPV4=example.com,www.example.com \ -e DDNS_INDEX4=['public',0] --network host \ --name ddns \ newfuture/ddns
想要了解所有支持的环境变量,请参考环境变量配置说明。
Docker 容器内的工作目录是 /ddns/,默认配置文件会被映射到容器内的 /ddns/config.json。
bashdocker run -v /host/config/:/ddns/ newfuture/ddns
其中 /host/config/ 是您本地包含 config.json 的目录。
详见 config.json 的内容可以参考 JSON 配置文件说明。
Network Modes:
host: Container uses host network, recommended for correct IP detectionbridge(default): Container has its own IP, usepublicmode to get public IP
使用 --network host 可让容器直接使用宿主机的网络,这样 DDNS 可以正确获取宿主机的 IP 地址。
对于 Public 或者 url 通常不需要设置 host
bashdocker run -d \ -e DDNS_DNS=dnspod \ -e DDNS_ID=12345 \ -e DDNS_TOKEN=mytokenkey \ -e DDNS_IPV4=example.com \ --network host \ newfuture/ddns
如果您不想使用 host 网络模式,也可以使用默认的 bridge 模式,但需要注意此时容器具有 IP,您需要使用 public 模式获取公网 IP:
环境变量方式配置多域名:
bashdocker run -d \ -e DDNS_DNS=dnspod \ -e DDNS_ID=12345 \ -e DDNS_TOKEN=mytokenkey \ -e DDNS_IPV4='["example.com", "www.example.com", "sub.example.com"]' \ --network host \ newfuture/ddns
命令行参数方式配置多域名:
bashdocker run --rm --network host newfuture/ddns \ --dns dnspod \ --id 12345 \ --token mytokenkey \ --ipv4 ipv4.example.com \ --ipv4 www.example.com
要在 Docker 容器中使用 IPv6,需要确保 Docker 守护程序配置了 IPv6 支持:
/etc/docker/daemon.json:json{ "ipv6": true, "fixed-cidr-v6": "fd00::/80" }
bashsudo systemctl restart docker
bashdocker run -d \ --network host \ -e DDNS_DNS=dnspod \ -e DDNS_ID=12345 \ -e DDNS_TOKEN=mytokenkey \ -e DDNS_IPV6=example.com \ newfuture/ddns
创建 docker-compose.yml 文件:
yamlversion: "3" services: ddns: image: newfuture/ddns:latest restart: always network_mode: host environment: - DDNS_DNS=dnspod - DDNS_ID=12345 - DDNS_TOKEN=mytokenkey - DDNS_IPV4=example.com,www.example.com - DDNS_INDEX4=['public','url:https://api.ipify.org'] - DDNS_LOG_LEVEL=WARNING
yamlversion: "3" services: ddns: image: newfuture/ddns:latest restart: always network_mode: host volumes: - ./config:/ddns
运行 Docker Compose:
bashdocker-compose up -d
如果您需要在容器中添加其他工具或自定义环境,可以基于官方镜像创建自己的 Dockerfile:
You can extend the official image with your own tools/scripts via Dockerfile.
dockerfileFROM newfuture/ddns:latest # 安装额外的工具 RUN apk add --no-cache curl # 添加自定义脚本 COPY custom-script.sh /bin/ RUN chmod +x /bin/custom-script.sh # 覆盖默认入口点(可选) # ENTRYPOINT ["/bin/custom-script.sh"]
Troubleshooting & FAQ:
- Can't get correct IP: use
--network hostor setDDNS_INDEX4=public- No scheduled updates: check logs, container status, or run update manually
- Container exits immediately: run with
-itfor debugging, check config- Network issues: check connectivity, set HTTP proxy if needed
问题: DDNS 无法正确获取主机 IP
解决方案:
--network host 网络模式-e DDNS_INDEX4=public 强制使用公网 API 获取 IP问题: 容器运行但不自动更新 DNS
解决方案:
docker logs ddnsdocker ps -adocker exec ddns /bin/ddns问题: 容器启动后立即退出
解决方案:
-it 参数以交互方式运行查看问题 docker run -it --rm newfuture/ddns问题: 容器无法连接到 DNS 服务商 API
解决方案:
docker exec ddns ping api.dnspod.cn-e DDNS_PROXY=http://proxy:port您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务