linux的docker中按照指定的redis.conf启动redis

  • 首先下载配置文件到指定的文件夹
   wget https://raw.githubusercontent.com/antirez/redis/4.0/redis.conf -O conf/redis.conf
  • 然后修改噢诶之文件中的相关配置
sed -i 's/logfile ""/logfile "access.log"/' redis.conf
sed -i 's/# requirepass foobared/requirepass 123456/' redis.conf
sed -i 's/appendonly no/appendonly yes/' redis.conf
sed -i 's/protected-mode yes/protected-mode no/' redis.conf
sed -i 's/bind 127.0.0.1/bind */' redis.conf
  • 最后运行镜像即可
docker run -p 6381:6379 --name redisByconf -v /home/fenglei/docker/redis/redis.conf:/usr/local/etc/redis/redis.conf   -v /home/fenglei/docker/redis/data:/data -d redis:4 redis-server /usr/local/etc/redis/redis.conf  --appendonly yes  --privileged=true
注解:
-v /home/fenglei/docker/redis/redis.conf:/usr/local/etc/redis/redis.conf 
:前面为你自定义的配置文件路径,后面的为docker容器运行镜像按照的文件路径

你可能感兴趣的:(服务器)