Docker安装Redis错误Reading the configuration file, at line 416 >>> 'locale-collate ""' Bad directive or wrong number of arguments

发布时间 2023-08-16 11:12:45作者: 蔚然丶丶

配置文件错误,去Redis的Github切换成Docker中同版本项目,复制redis.conf到本地

问题

启动docker,已经在映射目录中放了redis.conf配置文件,是从github中redis官方项目上面复制的,还是报错

docker run --restart=always \
-p 6379:6379 \
--name redis \
-v /mydata/redis/conf/redis.conf:/etc/redis.conf \
-v /mydata/redis/data:/data \
-d redis:7.0.12 redis-server /etc/redis.conf

查看日志

docker logs redis
*** FATAL CONFIG FILE ERROR (Redis 7.0.12) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 7.0.12) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 7.0.12) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 7.0.12) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

解决

参考docker - Dockerized 版本的 Redis 存在配置问题 - 堆栈溢出 (stackoverflow.com)

原因还是在redis.conf上,我复制的github中的redis官方最新版的配置文件,而docker中安装的redis和最新版本不同,配置文件中少了错误日志中的那几个配置,需要在github切换为docker中安装的同版本的redis.conf,复制下来,就不报错了。

切换为docker中拉取的同版本redis.conf

redis/redis.conf at unstable · redis/redis · GitHub

注意

不止redis,包括mysql等,在docker中安装时都与旧版本不同,比如配置文件位置不同、内容不同等等,在映射文件时要小心。