Eventually getting MISCONF errors even with volume specified using docker-compose
I start getting these errors soon after running the container:
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
Here's the relevant bit from my docker-compose.yml:
version: '3'
services:
redis:
command: redis-server --appendonly yes
container_name: task-conveyor-redis
image: redis:3.2-alpine
volumes:
- task-conveyor-data:/data
volumes:
task-conveyor-data:
I'm using Docker 17.05.0-ce-mac11 (17656).
I tried following the advice in this StackOverflow answer to no avail.
I've verified the redis user can write in /data as well:
/data # ls -al
total 8
drwxr-xr-x 2 redis redis 4096 May 19 18:16 .
drwxr-xr-x 1 root root 4096 May 19 06:19 ..
/data # su-exec redis touch testing
/data # ls -al
total 8
drwxr-xr-x 2 redis redis 4096 May 19 18:17 .
drwxr-xr-x 1 root root 4096 May 19 06:19 ..
-rw-r--r-- 1 redis redis 0 May 19 18:17 testing
User error. I started redis-cli and verified the value of the appendonly option, it was set to no which did not match the option specified in the command line. I was unaware that changing the command in docker-compose.yml only takes effect on rebuilding the image.
After a rebuild the problem is solved. ✨
Sorry, different MISCONF now:
MISCONF Errors writing to the AOF file: Invalid argument
It appears this happens when the qcow2 file has exceeded its maximum allowable size; clearing out unused images fixed the issue.
Hello! Tell me exactly what I need to do to fix this?
I just ran into this on my development laptop (a Mac). In my case, it turned out to be this Docker issue: https://forums.docker.com/t/no-space-left-on-device-error/10894/2.
My ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 file was at the max size, so I removed it and restarted Docker. Redis worked properly after that.
This error can also be caused by vm.overcommit_memory not being set to 1 on the Docker host. If you're using Docker Cloud, this is the case. Check with: docker exec -it {your-redis-container} cat /proc/sys/vm/overcommit_memory. In this case, when Redis memory usage grows to approx half of available memory, RDB save will fail because it cannot allocate memory when it forks.
See: https://redis.io/topics/faq#background-saving-fails-with-a-fork-error-under-linux-even-if-i-have-a-lot-of-free-ram
More possible fixes: https://stackoverflow.com/questions/36880321/why-redis-can-not-set-maximum-open-file
At redis startup we see:
redis_1 | 1:M 30 May 02:05:58.903 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
redis_1 | 1:M 30 May 02:05:58.903 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
redis_1 | 1:M 30 May 02:05:58.903 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
redis_1 | 1:M 30 May 02:05:58.903 * Running mode=standalone, port=6379.
redis_1 | 1:M 30 May 02:05:58.903 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
docker exec -it {your-redis-container} cat /proc/sys/vm/overcommit_memory
I had the same issue and could resolve it by doing what @mrmachine has suggested.