Skip to content

Commit 62a566e

Browse files
committed
fix: 修复 config.yaml 以只读方式挂载时容器启动失败 (Wei-Shaw#1113)
entrypoint 中 chown -R /app/data 在遇到 :ro 挂载的文件时报错退出, 添加错误容忍处理;同时去掉 compose 文件注释中的 :ro 建议。
1 parent 21f349c commit 62a566e

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

deploy/docker-compose.local.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ services:
3838
- ./data:/app/data
3939
# Optional: Mount custom config.yaml (uncomment and create the file first)
4040
# Copy config.example.yaml to config.yaml, modify it, then uncomment:
41-
# - ./config.yaml:/app/data/config.yaml:ro
41+
# - ./config.yaml:/app/data/config.yaml
4242
environment:
4343
# =======================================================================
4444
# Auto Setup (REQUIRED for Docker deployment)

deploy/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
- sub2api_data:/app/data
3131
# Optional: Mount custom config.yaml (uncomment and create the file first)
3232
# Copy config.example.yaml to config.yaml, modify it, then uncomment:
33-
# - ./config.yaml:/app/data/config.yaml:ro
33+
# - ./config.yaml:/app/data/config.yaml
3434
environment:
3535
# =======================================================================
3636
# Auto Setup (REQUIRED for Docker deployment)

deploy/docker-entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ set -e
66
# preventing the non-root sub2api user from writing files.
77
if [ "$(id -u)" = "0" ]; then
88
mkdir -p /app/data
9-
chown -R sub2api:sub2api /app/data
9+
# Use || true to avoid failure on read-only mounted files (e.g. config.yaml:ro)
10+
chown -R sub2api:sub2api /app/data 2>/dev/null || true
1011
# Re-invoke this script as sub2api so the flag-detection below
1112
# also runs under the correct user.
1213
exec su-exec sub2api "$0" "$@"

0 commit comments

Comments
 (0)