Docker初識:Redis服務的搭建(單機版)

一、版本說明:

系統:centos 7

docker:18

redis:6.0.3

二、單機服務搭建

1、下載redis

[root@VM_0_6_centos conf]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
redis                       latest              987b78fc9e38        3 weeks ago         104MB

2、新建配置文件redis.conf

[root@VM_0_6_centos standalone]# ls
conf  data  
[root@VM_0_6_centos standalone]# pwd
/opt/redis/standalone
[root@VM_0_6_centos standalone]# cd conf/
[root@VM_0_6_centos conf]# ls
redis.conf

redis.conf

bind 0.0.0.0
#是否禁止公網訪問redis cache 開啓條件 沒有bind IP  沒有設置requirepass訪問密碼
protected-mode no
#是否開啓守護模式
daemonize no
#aof日誌 每次寫操作都記錄一條日誌
appendonly yes
#是否開啓集羣
cluster-enabled no
#密碼
requirepass 123456

3、啓動命令

docker run -d  -p 6378:6379 --restart always --name redisStandalone -v /opt/redis/standalone/conf/redis.conf:/etc/redis/redis.conf -v /opt/redis/standalone/data:/etc/redis/data redis

4、查看鏡像

[root@VM_0_6_centos conf]# docker ps -a
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                     PORTS                              NAMES
ba0728d45348        redis                "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes               0.0.0.0:6378->6379/tcp             redisStandalone

5、測試是否成功

[root@VM_0_6_centos conf]# docker exec -it ba0728d45348 /bin/bash
root@ba0728d45348:/data# redis-cli -p 6379 -c
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> exit
root@ba0728d45348:/data# exit
exit
[root@VM_0_6_centos conf]#

或者使用RedisDesktopManager 連接查看。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章