redis/docker-library-redis

overriding redis.conf and networking issues

opyate opened this issue · 3 comments

opyate commented

I'm using Redis 7.4.0 via docker compose. This repo contains no redis.conf, so presumably you use the default conf in the main repo.

I downloaded the default conf at that tag.

Then tell compose to use it:

   redis:
     image: redis:7.4.0
+    command:
+      - redis-server
+      - /usr/local/etc/redis/redis.conf
+    volumes:
+    - ./redis:/usr/local/etc/redis
+    ports:
+      - 6379:6379

However, now for some reason, I get this error from my Python app:

redis.exceptions.ConnectionError: Error 111 connecting to redis:6379. Connection refused.

I still haven't made any changes to redis.conf.

Troubleshooting

Trying to determine if the "default default" config and "supplied default" config differs:

Before compose.yml change:

docker compose exec -ti redis redis-cli config get "*" > redis/config-supplied.txt

After compose.yml change:

docker compose exec -ti redis redis-cli config get "*" > redis/config-default.txt

Some pre-processing, as the keys are unordered:

paste -d ':' - - < redis/config-supplied.txt | sort > redis/sorted-config-supplied.txt
paste -d ':' - - < redis/config-default.txt | sort > redis/sorted-config-default.txt

Lo and behold, the 2 outputs differ:

% diff  redis/sorted-config-default.txt redis/sorted-config-supplied.txt                         
28c28
< bind:* -::*
---
> bind:127.0.0.1 -::1
113c113
< pidfile:
---
> pidfile:/var/run/redis_6379.pid
117c117
< protected-mode:no
---
> protected-mode:yes

I know the PID is irrelevant w.r.t docker and daemonisation, but the bind and protected-mode configs are the breaking change here.

Commenting all binds now gives:

redis.exceptions.ConnectionError: Error 104 while writing to socket. Connection reset by peer.

Changing bind to just be bind:* -::* gives:

redis.exceptions.ConnectionError: Error -3 connecting to redis:6379. Temporary failure in name resolution.

What worked in the end was having protected-mode:no and all binds commented.

If requested, I can send a PR to the doc for the Redis Docker Hub to have the "Additionally, if you want to use your own redis.conf ..." section reflect the above guidance?

@opyate the image uses the default config but modifies it slightly for the context of the container.

@LaurentGoderre

the image uses the default config but modifies it slightly for the context of the container

Yes, I've established that :)

From the diff in my comment you can see that the overridden config supplied by the Redis image has changes from the default.