Open vinezhang opened 6 months ago
If you tell redis-server
in the container to only listen on 127.0.0.1
via the bind
option in the config file, then it will not be accessible from outside that container. It will only be accessible from within the container's loopback device and thus not accessible from other containers or the Docker host running the container.
-p 6379:6379
on the docker run
will only direct traffic from all of the host IP addresses on the specified port to the routable IP of the container (like 172.17.0.2
or similar) on the given port. Since the redis-server
process is only bound to the container 127.0.0.1
, it won't respond.
I also met this problem, your answer solved my doubts, let me know why I can not access through 127.0.0.1 on the host, thank you. @yosifkit But is there a way to connect redis in docker on a host without changing the bind parameter value in the configuration file to 127.0.0.1?
I wanted to build an redis image with custom configuration file ,but I got above error when I connected it with AnotherRedisDesktopManager.
dockerfile
redis.conf copied from https://github.com/redis/redis/blob/2bf8c2c1300da1909cc8c8c35d13e46bcf59aa31/redis.conf. Only 'bind' and 'pid'`s value were changed
build command
run command