Skip to content

[Bug] OpenResty upgrade failed due to missing WEBSITE_DIR, causing /www mount error and rollback failure #13469

Description

@LHY0125

环境

  • 1Panel 版本:v2.2.4(全新安装,约 2026 年 2 月)
  • 系统:Ubuntu 24.04
  • OpenResty 版本:1.29.2.5-0-noble → 1.31.1.1-2-2-noble

问题描述

在应用商店升级 OpenResty(1.29.2.5 → 1.31.1.1),镜像拉取成功,但启动容器失败,随后回滚也失败。完整日志:

2026/08/04 17:29:17 升级应用 [openresty] 任务开始 [START]
2026/08/04 17:29:17 备份应用 [openresty] 成功
2026/08/04 17:29:23 开始拉取镜像 [1panel/openresty:1.31.1.1-2-2-noble]
2026/08/04 17:30:01 拉取镜像 成功
2026/08/04 17:30:12 开始执行 upgrade 脚本
2026/08/04 17:30:12 执行 upgrade 脚本 成功
2026/08/04 17:30:12 启动 应用
2026/08/04 17:30:12 升级应用 [openresty] 失败: stderr: time="2026-08-04T17:30:12+08:00" level=warning msg="The \"WEBSITE_DIR\" variable is not set. Defaulting to a blank string."
time="2026-08-04T17:30:12+08:00" level=warning msg="The \"WEBSITE_DIR\" variable is not set. Defaulting to a blank string."
time="2026-08-04T17:30:12+08:00" level=warning msg="The \"WEBSITE_DIR\" variable is not set. Defaulting to a blank string."
invalid spec: :/www: empty section between colons
, err: exit status 1
2026/08/04 17:30:12 应用 openresty 回滚
2026/08/04 17:30:12 应用 openresty 回滚 失败 : stderr: time="2026-08-04T17:30:12+08:00" level=warning msg="The \"WEBSITE_DIR\" variable is not set. Defaulting to a blank string."
time="2026-08-04T17:30:12+08:00" level=warning msg="The \"WEBSITE_DIR\" variable is not set. Defaulting to a blank string."
time="2026-08-04T17:30:12+08:00" level=warning msg="The \"WEBSITE_DIR\" variable is not set. Defaulting to a blank string."
invalid spec: :/www: empty section between colons
, err: exit status 1
2026/08/04 17:30:13 应用 openresty 回滚 成功
2026/08/04 17:30:14 [TASK-END]

根因分析(供参考)

升级模板 docker-compose.yml 中使用了 ${WEBSITE_DIR} 做挂载:

volumes:
  - ${WEBSITE_DIR}:/www
  - ${WEBSITE_DIR}/conf.d:/usr/local/openresty/nginx/conf/conf.d/
  - ${WEBSITE_DIR}/stream.d:/usr/local/openresty/nginx/conf/stream.d/

但现有 openresty 应用实例的 env 中没有设置 WEBSITE_DIR,导致变量展开为空 → 挂载变成 :/www → docker 拒绝启动。

关键点:当前正常运行的旧容器是用绝对路径挂载的(/opt/1panel/www -> /www),说明旧版本/旧实例不依赖该 env;而新模板要求该 env,但实例 env 里缺失,导致升级和回滚都失败。

复现步骤

  1. 应用商店 → OpenResty → 升级(1.29.2.5 → 1.31.1.1)
  2. 镜像拉取成功后,启动容器报错(见上日志)
  3. 升级失败后回滚,回滚同样报 :/www 错误

期望行为

  • 升级时应正确使用 /opt/1panel/www 作为 WEBSITE_DIR 的值,或在升级前校验该变量
  • 回滚不应失败(回滚失败会导致服务长时间不可用风险)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions