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相关配置。

相关推荐
weixin_307779131 小时前
Linux下Docker Compose里运行PostgreSQL数据库故障诊断Shell脚本
linux·运维·数据库·docker·postgresql
梦想的颜色2 小时前
【Docker 原理】Docker 数据持久化完全指南:三种挂载原理、数据卷实操、数据库落地实战
docker·云原生·数据持久化·volume·数据卷·容器挂载
qiu_lovejun9982 小时前
linux安装docker和redis和rabbitmq和nginx和rocketmq和kafka
linux·redis·docker·kafka·rabbitmq·rocketmq
源码学社2 小时前
Spug 3.0 Ubuntu 22.04 Docker 部署文档
linux·ubuntu·docker·windows安装·spug
石小千3 小时前
修改Docker Engine 存储路径
运维·docker·容器
xinyu3914 小时前
旧版Ubuntu Docker镜像 apt 失败
linux·ubuntu·docker
bin91535 小时前
使用Docker安装github项目 源码中含有 docker-compose.yml
docker·eureka·github
weixin_307779136 小时前
Linux下Docker Compose里运行Milvus向量数据库故障诊断Shell脚本
linux·运维·数据库·docker·milvus
SuperherRo6 小时前
云上攻防-云原生篇&Docker安全&Dockfile文件构建制作&不安全的镜像&不安全第三方组件
docker·dockerfile·不安全镜像·第三方组件