Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to
无法连接docker部署的redis出现原因:1、spring.redis.host2、连接时间spring.redis.timeout3、redis 没有设置密码spring.redis.password=解决方法:1、如果web服务器的镜像和redis镜像在一个宿主机上,spring.redis.host 不能使用宿主机的IP地址,解决方法如下Docker有4种网络模式,br...
·
无法连接docker部署的redis
出现原因:
1、spring.redis.host
2、连接时间spring.redis.timeout
3、redis 没有设置密码 spring.redis.password=
解决方法:
1、如果web服务器的镜像和redis镜像在一个宿主机上,spring.redis.host 不能使用宿主机的IP地址,解决方法如下
Docker有4种网络模式,bridge是默认的网络模式。
①、查看redis容器对应的容器ID是多少
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3961da6114c4 d3e35 “docker-entrypoint…” 4 days ago Up 4 days 0.0.0.0:6379->6379/tcp ecstatic_turing2
②、查看容器配置信息
# docker network inspect bridge
可以在Containers 信息中找到 ecstatic_turing的配置信息,如下
"3961da6114c4ee600438ec598703ec7312c6ecfde1b6055def0f910e0bc92632":
{
"Name": "ecstatic_turing",
"EndpointID": "4050d4e7d6c19c28258cc6a34bf0e589d22134c5eb02fea7f813606ee065c8b2",
"MacAddress": "02:42:ac:11:00:04",
"IPv4Address": "172.17.0.4/16",
"IPv6Address": ""
}
③、此时可以知道,配置spring.redis.host=172.17.0.4
2、将spring.redis.timeout=5000
3、如果redis没有设置密码,那就不写spring.redis.password= 或者只写 spring.redis.password=
更多推荐



所有评论(0)