5

Docker下安装Redis

 3 years ago
source link: https://www.cnblogs.com/MaSiy0104/p/14705664.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Docker下安装Redis

1:使用docker获取Redis镜像

docker pull redis(此处不加版本号表示拉取最新版本)

2:查看是否成功拉取Redis镜像

docker images

 3:准本修改Redis配置文件

Redis配置下载

基本参数说明:

  #注释掉下面这行代码表示开启外部访问

  #bind 127.0.0.1

#保护模式,限制为本地访问,修改后解除保护模式

  protected-mode yes

#使用守护线程的方式启动

  daemonize no

  #设置Redis密码
  requirepass 123456

  #开启持久化
  appendonly yes

4:创建Redis容器在本地文件的映射文件夹

mkdir -p /root/redis/data /root/redis/conf

5:创建Redis配置文件

touch /root/redis/conf/redis.conf

6:将修改好的配置文件内容粘进Linux中的配置文件

vim /root/redis/conf/redis.conf(进入编辑粘贴配置信息)

按ESC   输入        :wq(保存并退出)

7:启动Redis容器,并将Redis配置文件映射到本地conf文件夹

docker run -p 6379:6379 --name redis -v /root/redis/conf/redis.conf:/etc/redis/redis.conf -v /root/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes

(参数解释:

-p 将容器的端口映射到本机的端口

-v 将主机目录挂载到容器的目录

-e 设置参数  MYSQL_ROOT_PASSWORD 指定登录密码

-d 后台运行容器,也可以使用镜像id

--appendonly yes 开启持久化

8:查看是否成功启动Redis

docker ps


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK