redis / docker-library-redis

Docker Official Image packaging for Redis
http://redis.io
BSD 3-Clause "New" or "Revised" License
1.12k stars 567 forks source link

Redis can't write to disk - I'm out of ideas #380

Closed lockheed closed 11 months ago

lockheed commented 1 year ago

I use this docker compose:

version: "2.1"
services:
  broker:
    container_name: paperless-redis
    image: docker.io/library/redis:7
    restart: unless-stopped
    environment:
      PUID: 1000
      PGID: 1000
      TZ: Europe/Warsaw
    volumes:
      - /z/docker/_configs/paperless-ngx/redisdata:/data
    networks:
      - paperless-net

  paperless-ngx:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    container_name: paperless
    depends_on:
      - broker
    healthcheck:
      test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://localhost:8000"]
      interval: 30s
      timeout: 10s
      retries: 5
    environment:
      PUID: 1000
      PGID: 1000
      TZ: Europe/Warsaw
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_DATA_DIR: /config
      PAPERLESS_MEDIA_ROOT: /data/media
      PAPERLESS_TIME_ZONE: Europe/Warsaw
      PAPERLESS_URL: https://doks.impactor.one
    volumes:
      - /etc/localtime:/etc/localtime
      - /z/docker/_configs/paperless-ngx:/config
      - /z/data/paperless-data:/data
    restart: unless-stopped
    networks:
      - frontend
      - paperless-net

networks:
  frontend:
    external: true
  paperless-net:

When I try to upload document to paperless-ngx, it doesn't save it and complains

[2023-10-11 08:57:59,897] [ERROR] [celery.worker.consumer.consumer] consumer: Cannot connect to redis://broker:6379//: MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error..
Trying again in 32.00 seconds... (16/100)

because Redis complains:

1:M 11 Oct 2023 08:56:50.156 # Background saving error
1:M 11 Oct 2023 08:56:56.067 * 1 changes in 3600 seconds. Saving...
1:M 11 Oct 2023 08:56:56.067 * Background saving started by pid 26479
26479:C 11 Oct 2023 08:56:56.067 # Failed opening the temp RDB file temp-26479.rdb (in server root dir /data) for saving: Permission denied
1:M 11 Oct 2023 08:56:56.167 # Background saving error
1:M 11 Oct 2023 08:57:02.078 * 1 changes in 3600 seconds. Saving...
1:M 11 Oct 2023 08:57:02.078 * Background saving started by pid 26480
26480:C 11 Oct 2023 08:57:02.078 # Failed opening the temp RDB file temp-26480.rdb (in server root dir /data) for saving: Permission denied

All the disk permissions seem to be correct. I am out of ideas.

yosifkit commented 1 year ago

PUID/PGID aren't going to do anything for this image. Since you didn't set user:, the image will drop down from root and then run as the redis user in the container (user ID 999). It should've tried to chown the /data directory to 999 on start, but that may not have been possible depending on what the host path is.

You can double check what user it is running as by doing a docker top with the running container name.

lockheed commented 8 months ago

I think it is using user 999 # docker top paperless-redis UID PID PPID C STIME TTY TIME CMD 999 4173517 4173494 0 13:18 ? 00:00:00 redis-server *:6379

yosifkit commented 7 months ago

If you need uid/gid 1000 as your env vars seem to indicate and the host directory (/z/docker/_configs/paperless-ngx/redisdata) is already owned/writable by 1000, then user: "1000:1000" is the correct compose field/value to tell it to run as that user/group (https://docs.docker.com/compose/compose-file/05-services/#user).

lockheed commented 7 months ago

I made that modification and it seemed to work for 10 minutes, but then stopped again: paperless-ngx log: [2024-03-20 21:44:06,813] [ERROR] [celery.worker.consumer.consumer] consumer: Cannot connect to redis://broker:6379//: MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error..

redis log: 1:M 20 Mar 2024 22:40:30.112 # Background saving error 1:M 20 Mar 2024 22:40:36.022 * 1 changes in 3600 seconds. Saving... 1:M 20 Mar 2024 22:40:36.023 * Background saving started by pid 628 628:C 20 Mar 2024 22:40:36.023 # Failed opening the temp RDB file temp-628.rdb (in server root dir /data) for saving: Permission denied 1:M 20 Mar 2024 22:40:36.123 # Background saving error