在Windows Docker中安装Redis

本文的前提是本地Docker环境已经配置成功,参考Windows 10安装Docker并使用私钥连接AWS EC2

1. 参考资料

https://hub.docker.com/_/redis
https://redis.io/topics/config

2. 运行docker pull redis:6.2.4下载image

在Windows Docker中安装Redis

3. 下载redis.conf,并修改默认密码

# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
# layer on top of the new ACL system. The option effect will be just setting
# the password for the default user. Clients will still authenticate using
# AUTH <password> as usually, or more explicitly with AUTH default <password>
# if they follow the new protocol: both will work.
#
requirepass 123456

4. 启动redis server

运行docker run -v {CONFIG PATH}:/usr/local/etc/redis --name test-redis redis:6.2.4 redis-server /usr/local/etc/redis/redis.conf命令,终端将显示成功日志

1:C 12 Jun 2021 15:52:32.212 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 12 Jun 2021 15:52:32.212 # Redis version=6.2.4, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 12 Jun 2021 15:52:32.212 # Configuration loaded
1:M 12 Jun 2021 15:52:32.212 * monotonic clock: POSIX clock_gettime
                _._
           _.-``__ ‘‘-._
      _.-``    `.  `_.  ‘‘-._           Redis 6.2.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ‘‘-._
 (    ‘      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|‘` _.-‘|     Port: 6379
 |    `-._   `._    /     _.-‘    |     PID: 1
  `-._    `-._  `-./  _.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |           https://redis.io
  `-._    `-._`-.__.-‘_.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |
  `-._    `-._`-.__.-‘_.-‘    _.-‘
      `-._    `-.__.-‘    _.-‘
          `-._        _.-‘
              `-.__.-‘

1:M 12 Jun 2021 15:52:32.213 # Server initialized
1:M 12 Jun 2021 15:52:32.213 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1‘ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1‘ for this to take effect.
1:M 12 Jun 2021 15:52:32.214 * Ready to accept connections
1:M 12 Jun 2021 15:58:48.100 * DB saved on disk

或者运行docker run -v {CONFIG PATH}:/usr/local/etc/redis --name test-redis -d redis:6.2.4 redis-server /usr/local/etc/redis/redis.conf在后台运行

5. 使用redis-cli连接redis server

运行docker ps找到正在运行的redis container
在Windows Docker中安装Redis
运行docker exec -it {CONTAINER ID} redis-cli -a {PASSWORD}
在Windows Docker中安装Redis

在Windows Docker中安装Redis

上一篇:一个shell脚本实现应用启动|停止|重启|查看状态


下一篇:Windows phone 8 学习笔记(9) 集成