I see lots of people struggling with this, sort of feel like maybe there is a bug in the redis container image, and others seem to be chasing a similar problem.
I\'m usi
The problem is with your bind, You should set the following:
bind 0.0.0.0
This will set redis
to bind to all interfaces available, in a containerized environment with one interface, (eth0
) and a loopback (lo
) redis will bind to both of the above. You should consider adding security measures via other directives in config file
or using external tools like firewalls
. because with this approach everyone can connect to your redis
server.
The default setting is bind 127.0.0.1
and this setting will cause redis
to only listen on loopback interface, and it will be only accessible from inside the container. (for security)
To run redis with custom configuration file:
sudo docker run -d --name redis-test -p 6379:6379 -v /path/to/redisconf/redis.conf:/redis.conf redis redis-server /redis.conf
Now to verify on docker host with redis-tools
installed:
redis-cli
127.0.0.1:6379>
127.0.0.1:6379> set farhad likes:stackoverflow
OK
127.0.0.1:6379> get farhad
"likes:stackoverflow"
127.0.0.1:6379>
You can also connnect to your redis
container from an external host via:
redis-cli -h 'IP-address-of-dockerhost-running-redis-container'