17

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.

4
  • It must be something in your machine, I have tested your .yml file and it works for me Commented Jan 26, 2016 at 20:37
  • Are you sure it crashes because Redis cannot persist? That's not how Redis behaves Commented Jan 26, 2016 at 21:51
  • You can view the logs of your redis container with docker logs --follow <container_name or container_id>. Can you check and post it here? Commented Jan 26, 2016 at 23:26
  • Hello, I've added an excerpt of the log. Commented Jan 27, 2016 at 7:58

2 Answers 2

34
+25

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Could you maybe fork the repo, update to what you think it should be and send me a pull request? I've tried some stuff but because I'm very very new to docker, I don't really get it. Sorry.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.