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

相关推荐
东鹏特饮2 分钟前
Docker 容器技术详细指南
运维·docker·容器
开发者导航3 小时前
Tabby 教程:Docker 部署自托管 AI 编码助手
人工智能·docker·容器
Java码农也是农4 小时前
Docker 入门与实战:镜像、容器、数据卷和网络,用 Spring Cloud 部署讲清楚
网络·spring cloud·docker
墨痕诉清风6 小时前
OrbStack轻量级容器与虚拟机管理工具(docker)
运维·docker·容器
master3367 小时前
Docker 网络在不同操作系统内核上的实现方式
网络·docker·容器
csdn_aspnet8 小时前
在 Docker 中轻松运行 Oracle 数据库
数据库·docker·oracle·容器
Meaauf1 天前
Registry私有容器镜像仓库搭建
docker·容器·registry
always20221 天前
AI Infra · 02 - AI 感知的任务调度:Gang Scheduling、拓扑感知与潮汐弹性
人工智能·docker·kubernetes
Monkey的自我迭代1 天前
K8S详细学习1——为什么选择k8s
学习·docker·kubernetes
zjeweler1 天前
Nginx 502 Bad Gateway怎么解决?Docker反代与PHP-FPM报错全链路排查
nginx·docker·php-fpm·502 bad gateway·实用建站