Background

I previously ran cloudflare tunnel using docker, then updated the latest docker image today, but it won’t start after using the new image.

Symptom

I installed and run a connector of cloudflare tunnel with docker, and I ran the docker command provided of the tunnel like this:

1
docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token ${token}

But it fails to run and returns the following result:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Incorrect Usage: flag provided but not defined: -token

NAME:
   cloudflared tunnel run - Proxy a local web server by running the given tunnel

USAGE:
   cloudflared tunnel run [command options] TUNNEL-ID

OPTIONS:
   --force, -f  By default, if a tunnel is currently being run from a cloudflared, you can't simultaneously rerun it again from a second cloudflared. The --force flag lets you overwrite the previous tunnel. If you want to use a single hostname with multiple tunnels, you can do so with Cloudflare's Load Balancer product. (default: false)
   --help, -h   show help (default: false)

Reason

由于 cloudflared 升级之后,cloudflared tunnel run 命令出现了兼容性问题。旧命令与新版本不兼容,或者是文档未及时更新,回退 cloudflared 镜像版本即可。

Soultion

修改 docker 镜像的版本为旧版即可,由 cloudflare/cloudflared:latest -> cloudflare/cloudflared:2023.7.0

启动命令如下:

1
docker run cloudflare/cloudflared:2023.7.0 tunnel --no-autoupdate run --token ${token}