内容纲要
使用docker安装redis踩坑记录,redis版本使用的是7.2.3,默认安装没有问题,为了修改配置方便,从官网下载了redis.conf.txt配置文件,使用挂载方式运行redis。
-
容器运行命令
docker run --name redis-7.2.3 \ -p 6379:6379 \ -v /etc/localtime:/etc/localtime:ro \ -v /docker/redis-7.2.3/redis.conf:/etc/redis/redis.conf \ --privileged=true \ --restart=always \ -d redis:7.2.3 \ redis-server /etc/redis/redis.conf
-
系统运行后,发现redis无法从外部访问,查看并修改redis.conf配置文件
注释掉bind这行,让redis可以监听所有请求# You will also need to set a password unless you explicitly disable protected # mode. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bind 127.0.0.1 -::1
还没完,取消redis的保护模式运行,将protected-mode 的yes改为no
# By default protected mode is enabled. You should disable it only if # you are sure you want clients from other hosts to connect to Redis # even if no authentication is configured. protected-mode yes
重新启动redis容器,完毕