Redis Docker-copmpose Can't handle RDB format version 10 - docker

I can't start redis container in my docker-compose file. I know that docker-compose file is OK, because my colleagues can start the project successfully. I read that there is a solution to delete dump.rdb file. But I can't find it. I use Windows machine. Any suggestions will be very helpful.
Error
2023-02-09 16:41:28 1:M 09 Feb 2023 13:41:28.699 # Can't handle RDB format version 10
Redis in docker_compose:
redis:
container_name: redis
hostname: redis
image: redis:5.0
ports:
- "6379:6379"
volumes:
- redis:/data
restart: always

The solution was very simple:
docker volume ls
docker volume rm <volume_name>

Related

Docker-compose: Failed opening the temp RDB file temp-16.rdb (in server root dir /) for saving: Permission denied

I am using NodeJS + Express + Postgresql + Redis for my app.
My sql commands are working, but I am getting a permissions error when I am trying to update my redis cache:
cache | 16:C 27 Jun 2022 04:58:24.493 # Failed opening the temp RDB file temp-16.rdb (in server root dir /) for saving: Permission denied
cache | 1:M 27 Jun 2022 04:58:24.593 # Background saving error
Here is the cache portion of my docker-compose.yml:
cache:
container_name: cache
image: 'bitnami/redis:latest'
restart: always
ports:
- "6379:6379"
expose:
- 6379
command: redis-server --save 20 1 --loglevel warning --requirepass redis
volumes:
# - ./data:/data
- cache:/data
networks:
- my-network
I've read that the permissions must be set to read/write (obviously), but those that I found are for cases when using docker run. How can I do this using docker-compose?
Also, I don't think I have redis.conf. Any solutions that need it, can you please guide how to go about it?
Thanks!

Permission Denied when start the Redis in docker from Windows OS

Can anyone please explain what is the issue here and how to resolve that?
While I try to start the redis in docker desktop from windows OS, it always returning the error ""redis-redis-1 | 1:M 21 Jun 2022 14:40:59.452 # Can't open the append-only file: Permission denied
Here is my dockercompose file,
version: '2'
services:
redis:
image: 'docker.io/bitnami/redis:6.0-debian-10'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
ports:
- '6379:6379'
volumes:
- '/home/vagrant/var/Redis:/bitnami/redis/data'
The second image is the files from the redis-data folder.
In your docker-compose file, change the line:
'/home/vagrant/var/Redis:/bitnami/redis/data'
to
./redis_data/:/bitnami/redis/data/
Since redis_data is the folder you are trying to mount to the container.

WARNING: Sentinel was not able to save the new configuration on disk!!!: Device or resource busy

I am trying to setup one master one slave and one sentinel on docker, for that I wrote this docker compose file.
version: '3'
services:
redis-master:
container_name: "redis-master"
image: redis
ports:
- "6379:6379"
command: "redis-server /etc/redis.conf"
volumes:
- "./data/master:/data/"
- "./master.conf:/etc/redis.conf"
redis-slave:
container_name: "redis-slave"
image: redis
ports:
- "6380:6379"
command: "redis-server /etc/redis.conf"
volumes:
- "./data/slave:/data/"
- "./slave.conf:/etc/redis.conf"
depends_on:
- redis-master
redis-sentinel:
container_name: 'redis-sentinel'
image: redis
ports:
- "26379:26379"
command: >
bash -c "chmod 777 /etc/sentinel.conf
&& redis-server /etc/sentinel.conf --sentinel"
volumes:
- "./sentinel.conf:/etc/sentinel.conf"
depends_on:
- redis-master
- redis-slave
But when I try to build it using sudo docker-compose up --build --force all the services are runnning fine except the redis-sentinel. I got this error in logs
redis-sentinel | 1:X 16 Dec 2021 19:15:21.486 # +sdown master mymaster 172.23.0.2 6379
redis-sentinel | 1:X 16 Dec 2021 19:15:21.486 # +odown master mymaster 172.23.0.2 6379 #quorum 1/1
redis-sentinel | 1:X 16 Dec 2021 19:15:21.486 # +new-epoch 8
redis-sentinel | 1:X 16 Dec 2021 19:15:21.487 # +try-failover master mymaster 172.23.0.2 6379
redis-sentinel | 1:X 16 Dec 2021 19:15:22.955 # Could not rename tmp config file (Device or resource busy)
redis-sentinel | 1:X 16 Dec 2021 19:15:22.955 # WARNING: Sentinel was not able to save the new configuration on disk!!!: Device or resource busy
I understand this is some file permission and I have to make sentinel.conf executable but I am not able to think of any possible solutions in docker.
First of all, the sentinel command should be only like this (we will sort out the permissions later):
redis-server /etc/sentinel.conf --sentinel
In order to resolve that warning, you have to do the following (for all the redis nodes - master, slave, sentinel):
In the folder where the docker-compose.yml resides, create a "config" folder, with the following structure:
/config
/redis-master
redis.conf
/redis-slave
redis.conf
/redis-sentinel
redis.conf
Inside config/redis-master folder you copy your current master.conf file as redis.conf (for the sake of simplicity).
Inside config/redis-slave you copy your current slave.conf file as redis.conf
Inside config/redis-sentinel you will copy your current sentinel.conf as redis.conf
Then, execute this command, in order to give full rights to all the content of your "config" folder:
chmod -R 0777 config/
Now, change your service definitions in the docker-compose, like this:
(notice my changes in the "command" and "volumes" sections)
redis-master:
container_name: "redis-master"
image: redis
ports:
- "6379:6379"
command: "redis-server /etc/redis-config/redis.conf"
volumes:
- "./data/master:/data/"
- "./config/redis-master:/etc/redis-config"
redis-slave:
container_name: "redis-slave"
image: redis
ports:
- "6380:6379"
command: "redis-server /etc/redis-config/redis.conf"
volumes:
- "./data/slave:/data/"
- "./config/redis-slave:/etc/redis-config"
depends_on:
- redis-master
redis-sentinel:
container_name: 'redis-sentinel'
image: redis
ports:
- "26379:26379"
command: "redis-server /etc/redis-config/redis.conf --sentinel"
volumes:
- "./config/redis-sentinel:/etc/redis-config"
depends_on:
- redis-master
- redis-slave
Conclusions:
In order for redis to have rights to modify the configurations, you have mount the entire configuration folder, not the file itself (and the folder contents should be writable).
Back-up all the original master.conf, slave.conf, sentinel.conf files. Be aware that redis will alter your local configuration files (redis.conf), because eventually you will execute failovers, so the slave config will be turned into a master one and the opposite for the master config. It's up to you how you avoid committing the changes to source control. For example, you can keep the originals in a separate folder, and copy them to the mounted folder by a deploy script, before running "docker-compose up" command.
All the changes that redis will apply to these config files will be appended at the end of the config and will be preceded by this comment:
# Generated by CONFIG REWRITE
This solution is tested by me and it works. I came out with this solution after reading #yossigo 's answer regarding a similar warning:
https://github.com/redis/redis/issues/8172

Bad log time in Docker

I have *.yml file to keycloak example and when i want see logs in console then i use:
docker logs -f keycloak
example logs:
08:41:27,304 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
When i go into docker
docker exec -it keycloak bash
and run date then i have correct time like
[root#3741ebb1131f /]# date
Mon Nov 14 14:44:41 CET 2016
My yml file:
version: '2'
services:
keycloak:
image: bla_bla_bla_image
container_name: keycloak
volumes:
- /etc/localtime:/etc/localtime:ro
external_links:
- postgres_container:postgres
networks:
default:
ipv4_address: "111.111.11.11"
networks:
default:
external:
name: demo
Can someone tell me what is happen?

Why can't redis access the disk in docker-compose?

I tried a very simple first test of a python app with a redis according to the docker documentation. This crashes after a while because redis cannot persist. I don't have a clue why. You can find the public repo here: Github repo
My current docker-compose.yml is:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
redis:
image: redis:latest
volumes:
- ./data:/data
Edit: this is an excerpt of the log:
1:M 09 Feb 10:51:15.130 # Background saving error
1:M 09 Feb 10:51:21.072 * 100 changes in 300 seconds. Saving...
1:M 09 Feb 10:51:21.073 * Background saving started by pid 345
345:C 09 Feb 10:51:21.074 # Failed opening .rdb for saving: Permission denied
1:M 09 Feb 10:51:21.173 # Background saving error
1:M 09 Feb 10:51:27.011 * 100 changes in 300 seconds. Saving...
1:M 09 Feb 10:51:27.011 * Background saving started by pid 346
346:C 09 Feb 10:51:27.013 # Failed opening .rdb for saving: Permission denied
Edit2: this is the complete error Redis throws in python:
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
The funny thing is, I don't do anything to the redis image.
It is a permission error, log into the redis container via docker exec -it redis_container_name bash and ensure it has write permissions on /data.
It probably does not, and you can fix it several ways: use a docker volume instead of bind-mounting the host, or try to fix permissions from the host by having matching uid/gid with the owner in the container.
Also, as stated in the docker hub page, you should set redis' command to:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
redis:
image: redis:latest
command: redis-server --appendonly yes
volumes:
- ./data:/data
if you intend to persist data.
Since your data folder has the wrong permissions set, start by deleting it and letting docker-compose make a new one.
I have updated my repo with a working version, tag 0.2
Once I worked with version 2 of the docker file it worked fine.

Resources