From 31640363fc0a94cc507b756c540fc4a3c73f3393 Mon Sep 17 00:00:00 2001 From: WANG TAIRAN Date: Wed, 17 Jun 2026 10:42:16 +0800 Subject: [PATCH] fix(deploy): add :Z SELinux labels to bind mounts Add the :Z (private unshared) SELinux label to all bind-mounted directories in docker-compose.local.yml and docker-compose.dev.yml. On systems with SELinux in Enforcing mode (e.g. Fedora, RHEL, CentOS), containers using bind mounts are denied access to host directories because the default 'user_home_t' context is not accessible to container processes. The :Z label tells the container runtime to relabel the mount point with 'container_file_t' so the container can read/write it. Named volumes in docker-compose.yml are not affected because the runtime already handles their labels automatically. Fixes permission-denied errors on: - ./data:/app/data - ./postgres_data:/var/lib/postgresql/data - ./redis_data:/data --- deploy/docker-compose.dev.yml | 6 +++--- deploy/docker-compose.local.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deploy/docker-compose.dev.yml b/deploy/docker-compose.dev.yml index 47e0bcad0c..7755fdbeff 100644 --- a/deploy/docker-compose.dev.yml +++ b/deploy/docker-compose.dev.yml @@ -18,7 +18,7 @@ services: ports: - "${BIND_HOST:-127.0.0.1}:${SERVER_PORT:-8080}:8080" volumes: - - ./data:/app/data + - ./data:/app/data:Z environment: - AUTO_SETUP=true - SERVER_HOST=0.0.0.0 @@ -73,7 +73,7 @@ services: container_name: sub2api-postgres-dev restart: unless-stopped volumes: - - ./postgres_data:/var/lib/postgresql/data + - ./postgres_data:/var/lib/postgresql/data:Z environment: - POSTGRES_USER=${POSTGRES_USER:-sub2api} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required} @@ -94,7 +94,7 @@ services: container_name: sub2api-redis-dev restart: unless-stopped volumes: - - ./redis_data:/data + - ./redis_data:/data:Z command: > sh -c ' redis-server diff --git a/deploy/docker-compose.local.yml b/deploy/docker-compose.local.yml index ec5a66daeb..b15be2402d 100644 --- a/deploy/docker-compose.local.yml +++ b/deploy/docker-compose.local.yml @@ -35,7 +35,7 @@ services: - "${BIND_HOST:-0.0.0.0}:${SERVER_PORT:-8080}:8080" volumes: # Local directory mapping for easy migration - - ./data:/app/data + - ./data:/app/data:Z # Optional: Mount custom config.yaml (uncomment and create the file first) # Copy config.example.yaml to config.yaml, modify it, then uncomment: # - ./config.yaml:/app/data/config.yaml @@ -192,7 +192,7 @@ services: hard: 100000 volumes: # Local directory mapping for easy migration - - ./postgres_data:/var/lib/postgresql/data + - ./postgres_data:/var/lib/postgresql/data:Z environment: - POSTGRES_USER=${POSTGRES_USER:-sub2api} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required} @@ -223,7 +223,7 @@ services: hard: 100000 volumes: # Local directory mapping for easy migration - - ./redis_data:/data + - ./redis_data:/data:Z command: > sh -c ' redis-server