文档/安装 wantasticd5 分钟Docker · Compose

在 Docker 中运行(社区方案)

在基于官方发布版本构建的 Docker 容器中运行 wantasticd:构建一个小镜像,用 genkey 认领一次,然后以后台方式运行。这不是官方镜像。

完成后你将得到

你自行构建的容器运行 wantasticd,将认领信息保存在命名卷中,自动重启,并在控制台中显示为 Online。

开始之前

  • 带有 TUN 驱动的 Linux 主机上的 Docker Engine 20.10+(或 Podman)。
  • 有权限使用 --cap-add NET_ADMIN 和 --device /dev/net/tun 运行容器。
  • 一部手机或一个浏览器,用于登录 Wantastic 控制台。

快速安装(5 分钟)

没有官方镜像。你需要基于官方发布版本构建一个小镜像,认领一次,然后在后台运行。无需令牌。

  1. 1将下方的 Dockerfile 保存到一个空目录中。将 WANTASTIC_ARCH 设置为主机的 CPU 类型(amd64、arm64 或 arm)。
  2. 2构建镜像,并用认领命令运行一次 genkey。它会打印 Claim URL 和二维码。
  3. 3扫描二维码或打开 Claim URL,登录后点击 Claim Device。
  4. 4打印出 "Device claimed" 后,按 Ctrl+C。认领信息已保存在 wantastic 卷中。
  5. 5使用运行命令在后台启动容器。
Dockerfiledockerfile
FROM alpine:3.20
ARG WANTASTIC_ARCH=amd64
RUN apk add --no-cache ca-certificates curl \
 && TAG=$(curl -fsSL https://get.wantastic.app/latest | cut -d+ -f1) \
 && mkdir -p /tmp/w \
 && curl -fsSL https://get.wantastic.app/$TAG/wantasticd-linux-$WANTASTIC_ARCH.tar.gz | tar -xz -C /tmp/w \
 && install -m 755 "$(find /tmp/w -name wantasticd -type f | head -n 1)" /usr/local/bin/wantasticd \
 && rm -rf /tmp/w \
 && wantasticd version
ENV WANTASTIC_CONFIG_DIR=/etc/wantastic \
    WANTASTIC_DNS_MODE=off
VOLUME /etc/wantastic
ENTRYPOINT ["wantasticd"]
CMD ["connect", "--config", "/etc/wantastic/config.conf", "--no-auto-update"]
构建并认领(一次)bash
docker build -t wantasticd-local --build-arg WANTASTIC_ARCH=amd64 .
docker run -it --rm --hostname office-docker --cap-add NET_ADMIN --device /dev/net/tun -v wantastic:/etc/wantastic wantasticd-local genkey
在后台运行bash
docker run -d --name wantasticd --hostname office-docker --restart unless-stopped --cap-add NET_ADMIN --device /dev/net/tun -v wantastic:/etc/wantastic wantasticd-local
安装并认领
$ docker run -it --rm --hostname office-docker --cap-add NET_ADMIN --device /dev/net/tun -v wantastic:/etc/wantastic wantasticd-local genkey
…
…
Generated device claim key: /etc/wantastic/device-claim-key.json
Public key: Vd3hK1oQ7mR2sT9uW4xY6zA8bC0dE2fG4hJ6kL8mN0P=
Server URL: https://console.wantastic.app
Claim URL: https://console.wantastic.app/#desktop?claim_public_key=Vd3hK1oQ…%3D&wantastic_server=https%3A%2F%2Fconsole.wantastic.app1
 
█▀▀▀▀▀█ ▄▀▄ ▀█▄ █▀▀▀▀▀█
█ ███ █ ▀█▄▀▄█ █ ███ █
█ ▀▀▀ █ ▄▀█ ▀▄ █ ▀▀▀ █
▀▀▀▀▀▀▀ ▀ ▀ █ ▀ ▀▀▀▀▀▀▀
▀█▄▀▄▀▀█▀▄█▀▄▀▀▄█▀▄▀█▄
█▀▀▀▀▀█ █▄▀▄▀█ ▀▄█ ▄▀
▀▀▀▀▀▀▀ ▀▀ ▀▀▀ ▀▀▀ ▀▀▀
 
2026/10/29 09:14:03 Waiting for claim. Press Ctrl+C to stop.
2026/10/29 09:15:12 Device claimed. Configuration saved to /etc/wantastic/config.conf2
^C
$ docker run -d --name wantasticd --hostname office-docker --restart unless-stopped --cap-add NET_ADMIN --device /dev/net/tun -v wantastic:/etc/wantastic wantasticd-local3
  1. 1打开此链接,或扫描二维码
  2. 2已认领:现在按 Ctrl+C
  3. 3重启一次服务
genkey 打印 Claim URL 和二维码后进入等待。你在控制台中点击 Claim Device 后,它会打印 "Device claimed"。然后按 Ctrl+C 并重启服务。
控制台视图
Claim Wantastic Device
1
Claim public key
q3Xv…9f2Q= (44 characters)
2
Wantastic server
https://console.wantastic.app
Cancel3Claim Device
  1. 1Claim public key 已自动填写
  2. 2Wantastic server 保持默认即可
  3. 3点击 Claim Device
Claim Wantastic Device。Claim URL 和二维码会自动填入密钥,你只需点击 Claim Device。

注意: WANTASTIC_DNS_MODE=off 可防止代理修改由 Docker 管理的容器 DNS。容器中的自动更新处于关闭状态:如需更新,请重新构建镜像。

检查是否正常工作

  1. 1运行状态命令。它会显示 Status: Connected。
  2. 2在控制台中打开 Devices。设备显示为 Online。
检查bash
docker exec wantasticd wantasticd status
docker logs --tail 20 wantasticd
wantasticd status
$ docker exec wantasticd wantasticd status
Status: Connected1
Version: v1.0.54+377f3c0
Mode: TUN (wantastic0)
VPN IPs: 10.200.0.14/322
Public key: q7ZkV3m1yH0dTn8pXo2bLwR4sE6uJ9cA1fG5hK8iN0M=
Server: wg.wantastic.app:51820
Exit node: false
Local access: false
Auto update: true
Traffic: ↓ 18.4 KiB ↑ 9.2 KiB
Peers: 2 (direct 1, relay 1)
Uptime: 4m12s
  1. 1隧道已建立
  2. 2你的覆盖网络地址
Status: Connected 加上 VPN IP 表示隧道已建立。
控制台视图
Devices
1
Search by name, IP, or key...
Select AllAdd Device
DeviceTypeVPN IPStatusSeenActions
HQ-CCR2004MikroTik310.88.0.22Online4Now
Branch-hAP-ax3MikroTik10.88.0.3Online12s ago
Tower-12-OpenWrtwantasticd10.88.0.4Online4s ago
NOC-Ubuntu-01wantasticd10.88.0.5Offline3 h ago
  1. 1按名称搜索
  2. 2状态显示 Online
  3. 3覆盖网络 IP 与 wantasticd status 一致
  4. 4Last seen 持续更新
Devices 窗口:新设备以其名称出现,并在几秒钟内变为 Online。

Docker Compose

  • 默认网络:只有容器位于覆盖网络中。
  • network_mode: host 会将 wantastic0 放到主机上,这样主机本身也可以通过覆盖网络访问。
compose.yamlyaml
services:
  wantasticd:
    build:
      context: .
      args:
        WANTASTIC_ARCH: amd64
    image: wantasticd-local
    hostname: office-docker
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    volumes:
      - wantastic:/etc/wantastic
    # network_mode: host   # put wantastic0 on the host itself
volumes:
  wantastic: {}
认领一次,然后启动bash
docker compose run --rm wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
docker compose up -d

更新

使用最新发布版本重新构建bash
docker build --no-cache -t wantasticd-local --build-arg WANTASTIC_ARCH=amd64 .
docker rm -f wantasticd
# then run the "Run in the background" command again (the volume keeps the claim)

其他安装方式

仅在自动化或特殊情况下才需要这些方式。上面的快速安装是最简单的方法。

使用 Account → Secrets 中的令牌向卷中登录一次,然后使用运行命令。

使用令牌登录到卷bash
docker run --rm --hostname office-docker -v wantastic:/etc/wantastic wantasticd-local login --no-connect --token <TOKEN>

像对待密码一样对待令牌。在其过期之前,任何持有它的人都能向你的账户添加设备。

控制台视图
My Account
ProfileSecuritySessions2FA1SecretsSnapshotsWidgetsMCP
Enrollment Secrets
2+ New Secret
3
Secret Name
noc-rollout
Expiry (Days, 0 for never)
7
Max Uses (0 for unlimited)
25
4Generate
5
noc-rolloutwnt_••••••••3f9a3 / 25 uses · 6 days left
Device claim QRShow Enrollment Script
  1. 1打开 Secrets 选项卡
  2. 2点击 + New Secret
  3. 3为其命名
  4. 4点击 Generate
  5. 5复制新密钥
Account → Secrets → + New Secret。密钥的值就是令牌。

验证结果

docker ps 显示 wantasticd 为 Up(而不是 Restarting)。
docker exec wantasticd wantasticd status 显示 Status: Connected。
设备在 Devices 中显示为 Online。

常见问题

容器因 TUN 错误立即停止。Failed to start agent: create device: create tun: CreateTUN("wantastic0") failed; /dev/net/tun does not existdocker logs
原因

启动容器时没有使用 --device /dev/net/tun,或主机没有 TUN 驱动。

解决方法

在主机上加载 TUN,然后使用快速安装中的确切运行命令。

在主机上bash
sudo modprobe tun
容器因权限错误而停止。operation not permitteddocker logs
原因

缺少 NET_ADMIN 能力,或运行时为 rootless 模式。

解决方法

添加 --cap-add NET_ADMIN。使用 rootless Docker 或 Podman 时,请以 root 身份运行容器。

容器启动后立即循环重启。Config not found at /etc/wantastic/config.conf. Run `wantasticd genkey --out <key>` to create a claim key and wait for claim, or pass --wait-claim with an existing key.docker logs
原因

容器从未被认领,或使用了不同的卷。

解决方法

使用相同的卷名运行一次认领命令,然后再次启动容器。

认领bash
docker run -it --rm --hostname office-docker --cap-add NET_ADMIN --device /dev/net/tun -v wantastic:/etc/wantastic wantasticd-local genkey
docker restart wantasticd
在容器内运行 install.sh 时在最后失败。System has not been booted with systemd as init system (PID 1). Can't operate.install.sh
原因

容器通常没有 systemd。

解决方法

请使用本页的 Dockerfile,而不是安装程序。

日志每小时都显示更新失败。Error: no supported service manager found; refusing an unverifiable updatedocker logs
原因

自动更新已开启,但容器没有服务管理器。

解决方法

在 CMD 中保留 --no-auto-update(与 Dockerfile 中相同),并通过重新构建镜像来更新。

认领或登录被拒绝。Login failed: account has reached its device limit — upgrade your plan or remove an existing devicewantasticd login / 控制台
原因

你的套餐设备数量已满。控制台显示 "You have reached the maximum number of devices for your plan."

解决方法

在 Devices 中删除一台不再使用的设备(设备行 → Delete),或升级套餐。然后重新认领。

status 显示 Running (tunnel down),或 peers 显示 (server) 为 HANDSHAKE never。Device health check failed: …服务日志
原因

网络阻止了到中心节点(wg.wantastic.app)的出站 UDP 51820 端口,或 DNS 不可用。

解决方法

在防火墙中放行出站 UDP 51820,然后重启服务。

测试 DNS 并重启bash
nslookup wg.wantastic.app
docker restart wantasticd
验证: wantasticd peers 显示 (server) 有最近的握手(例如 "8s ago")。

继续阅读

仍然无法解决?

请通过邮件发送设备名称、平台和完整的错误文本。切勿发送令牌、密钥或密码。

hello@wantastic.app