You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Redis配置持续自动重置,未重启Docker容器仍恢复原值求助

Troubleshooting Redis Dir Configuration Reverting in Docker

Let's break down possible reasons why your Redis dir setting keeps reverting to /etc/crontabs even without restarting the container, and how to fix them:

1. Missing CONFIG REWRITE After CONFIG SET

When you run CONFIG SET dir "/data", this only modifies the running in-memory configuration of Redis—it doesn’t save the change to your actual config file. If any process triggers Redis to reload its config file (like a SIGHUP signal sent to the Redis process), it will fall back to the original value from the file.

To lock in the change:

  • Right after running CONFIG SET dir "/data", execute this command to write the running config back to your Redis config file:
    redis-cli CONFIG REWRITE
    

This ensures future config reloads will use your new dir value instead of the old one.

2. Check for Automated Crontab Scripts

Since the reverted path is /etc/crontabs, there’s a strong chance a scheduled task in your container is overriding the Redis config. Here’s how to investigate:

  • Enter your Redis container to inspect crontabs:
    docker exec -it <your-redis-container-id> /bin/bash
    
  • List all active cron jobs:
    crontab -l
    
  • Check the /etc/crontabs directory for scripts that might run redis-cli commands to reset the dir setting:
    ls -la /etc/crontabs
    cat /etc/crontabs/*
    

If you find a script that’s modifying the Redis config, either update it to stop changing the dir value or remove the cron job entirely.

3. Verify Docker Volume Mounts and Config File Integrity

If you’re starting the container with a custom config file, double-check these details:

  • Ensure your custom config file is correctly mounted into the container (review your docker run command or docker-compose.yml volume settings). A broken mount could mean Redis is using a default config file instead of your custom one.
  • Confirm the dir directive in your config file is set to /data (not /etc/crontabs). Check the file content inside the container:
    cat /path/to/your/redis.conf | grep "dir "
    
  • Make sure the Redis process has write permissions to the config file (so CONFIG REWRITE can work properly). Check permissions with:
    ls -la /path/to/your/redis.conf
    

4. Rule Out External Config Sync Tools

If your Docker environment uses tools like Consul, etcd, or a custom configuration sync service, these might be periodically pushing a default config to Redis. Verify if any such tools are running alongside your container and adjust their settings to preserve your dir configuration.


内容的提问来源于stack exchange,提问作者sukidesuaoi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:33:37