Docker redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused

Docker redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused

redis-cli is the Redis command line interface, 用来与Redis服务进行交互,是因为Redis服务尚未启动。且docker启动redis里面没有配置文件。需要自己建立redis配置文件。

[root@centos7 ~]# docker inspect redis-master | grep -i volume
            "VolumeDriver": "",
            "VolumesFrom": null,
                "Type": "volume",
                "Source": "/docker/volumes/8a29c5a2460e0e7f6555ea5ad139ba6d522116d9c659be5e2a97f201bb23a812/_data",
            "Volumes": {
[root@centos7 ~]# cd /docker/volumes/8a29c5a2460e0e7f6555ea5ad139ba6d522116d9c659be5e2a97f201bb23a812/_data
[root@centos7 _data]# vim redis.conf
[root@centos7 _data]# cat redis.conf 
daemonize yes
pidfile /var/run/redis.pid
[root@centos7 _data]# docker exec -it redis-master /bin/bash
root@a5278da0079c:/data# redis-server /data/redis.conf 
root@a5278da0079c:/data# redis-cli 
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> 
posted @ 2021-07-01 14:47  素丶素  阅读(1084)  评论(0编辑  收藏  举报