Cloudflare Tunnel docker-compose.yml

Cloudflare使用docker compose部署方式时,特别是在aliyun服务器上进行部署时,需要注意docker pull拉取时的版本,版本较老时,可能会遇到tunnel command参数问题:

WARN0001 The "TUNNEL_TOKEN" variable is not set. Defaulting to a blank string.

导致docker一直重启(设置了restart规则时)。此时token为设置成功,Cloudflare无法捕获tunnel。

遇到这种情况时可以使用指定版本来解决:

XML 复制代码
services:
  cloudflared:
    image: cloudflare/cloudflared:1871-81a53555aa82
    container_name: cloudflared
    restart: unless-stopped
    # Logging configuration for Cloudflare Tunnel container
    logging:
      driver: "json-file"                             # Use the default json-file logging driver
      options:
        max-size: "100m"                              # Maximum log file size before rotation (100 MB)
        max-file: "5"                                # Maximum number of log files to retain (10)
    command: tunnel --no-autoupdate run              # Command to start the Cloudflare tunnel
    # Volume configuration for time synchronization and hosts file persistence
    volumes:
      - /etc/localtime:/etc/localtime:ro              # Synchronize time with the host
    # Environment variables for Cloudflare Tunnel
    environment:
      - TUNNEL_TOKEN=${TUNNEL_TOKEN}

在docker-compose.yml同级文件夹下新建.env文件,内容为:

bash 复制代码
# 不要加引号
TUNNEL_TOKEN=Your Token

这样就可以顺利启动docker,然后在cloudflare网站中继续设置tunnel相关配置。

相关推荐
bigbig_ben20 小时前
yearning安装docker
运维·docker·容器
吴声子夜歌1 天前
Docker入门与实战——热门镜像介绍
运维·docker·容器
方便面不加香菜1 天前
容器虚拟化基础--CGroups资源控制
运维·docker·容器
BioRunYiXue1 天前
使用docker分析高通量测序数据
java·数据库·人工智能·spring cloud·docker·tomcat·html
吴声子夜歌1 天前
Docker入门与实战——Docker命令查询
docker·容器
handonch1 天前
金仓 KingbaseES 时区问题根治指南:从「总是差 8 小时」到全链路统一
linux·docker·postgresql·信创
吴声子夜歌1 天前
Docker入门与实战——常见问题总结
运维·docker·容器
马立杰1 天前
Docker Build 编译补丁版 PHP7.4 FPM 容器镜像教程(CVE-2026-109618 CVE-2026-109619)
运维·docker·容器·php
tedcloud1232 天前
Docker Compose 部署 Memos:从安装到备份恢复
linux·开发语言·jvm·后端·docker·容器·rust
无人生还别怕2 天前
如何搭建k8s服务(docker部署)
linux·运维·docker·云原生·容器·kubernetes·openanolisos