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>