最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

docker - Redis delete data after a while - Stack Overflow

programmeradmin1浏览0评论

I have a redis docker container as this compose content

  redis:
    image: redis:alpine
    network_mode: host
    env_file: .env
    command: ["sh", "-c", "redis-server --port $${REDIS_PORT}"]
    volumes:
      - ./docker_data/redis/data:/data

But after a while the data remove automatically.

there is no specific configuration in .env file to modify redis behaviour and the values doesn't have any TTL

When i wrote the service as this:

  redis:
    image: redis:alpine
    volumes:
      - ./docker_data/redis/data:/data

It works without any problem.

Also this is the container log:
redis-1  | 1:C 05 Feb 2025 13:05:27.004 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1  | 1:C 05 Feb 2025 13:05:27.004 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1  | 1:C 05 Feb 2025 13:05:27.004 # Configuration loaded
redis-1  | 1:M 05 Feb 2025 13:05:27.005 * monotonic clock: POSIX clock_gettime
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * Running mode=standalone, port=6379.
redis-1  | 1:M 05 Feb 2025 13:05:27.006 # Server initialized
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * Loading RDB produced by version 7.0.11
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * RDB age 1491 seconds
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * RDB memory usage when created 0.85 Mb
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * Done loading RDB, keys loaded: 6, keys expired: 0.
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * DB loaded from disk: 0.000 seconds
redis-1  | 1:M 05 Feb 2025 13:05:27.006 * Ready to accept connections
redis-1  | 1:M 05 Feb 2025 13:55:18.975 * DB saved on disk
redis-1  | 1:M 05 Feb 2025 13:55:19.307 * DB saved on disk
redis-1  | 1:M 05 Feb 2025 13:55:20.456 * DB saved on disk
redis-1  | 1:M 05 Feb 2025 13:55:20.788 * DB saved on disk
redis-1  | 1:M 05 Feb 2025 13:55:20.956 * DB saved on disk
redis-1  | 1:M 05 Feb 2025 13:55:22.109 * DB saved on disk
redis-1  | 1:M 05 Feb 2025 13:55:22.968 * DB saved on disk

I want to run redis in host mode with configurable port from environment variables

发布评论

评论列表(0)

  1. 暂无评论