Docker安装官方Redis镜像并启用密码认证
作者:JanelSirry 时间:2021-07-19 20:34:55
参考:docker官方redis文档
1.有特殊版本需求的可以查看redis镜像tag版本
3.2.11, 3.2, 3 (3.2/Dockerfile)
3.2.11-32bit, 3.2-32bit, 3-32bit (3.2/32bit/Dockerfile)
3.2.11-alpine, 3.2-alpine, 3-alpine (3.2/alpine/Dockerfile)
4.0.9, 4.0, 4, latest (4.0/Dockerfile)
4.0.9-32bit, 4.0-32bit, 4-32bit, 32bit (4.0/32bit/Dockerfile)
4.0.9-alpine, 4.0-alpine, 4-alpine, alpine (4.0/alpine/Dockerfile)
2.选择最新版latest
docker pull redis:latest
[root@localhost~]# docker pull redis:latest
latest: Pulling from library/redis
4d0d76e05f3c: Pull complete
cfbf30a55ec9: Pull complete
82648e31640d: Pull complete
fb7ace35d550: Pull complete
497bf119bebf: Pull complete
89340f6074da: Pull complete
Digest: sha256:166788713c58c2db31c41de82bbe133560304c16c70e53a53ca3cfcf35467d8a
Status: Downloaded newer image for redis:latest
3.启动容器并带密码
docker run --name redis-test -p 6379:6379 -d --restart=always redis:latest redis-server --appendonly yes --requirepass "your passwd"
-p 6379:6379 :将容器内端口映射到宿主机端口(右边映射到左边)
redis-server –appendonly yes : 在容器执行redis-server启动命令,并打开redis持久化配置
requirepass “your passwd” :设置认证密码
–restart=always : 随docker启动而启动
4.查看容器
docker ps
[root@localhost~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a126ec987cfe redis:latest "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:6379->6379/tcp redis-test
3645da72ece6 portainer/portainer "/portainer" 7 days ago Up 7 days 0.0.0.0:9000->9000/tcp sharp_lovelace
118ba79de20a hwdsl2/ipsec-vpn-server "/opt/src/run.sh" 12 days ago Up 12 days 0.0.0.0:500->500/udp, 0.0.0.0:4500->4500/udp l2tp-vpn-server
848fdba6de60 kylemanna/openvpn "ovpn_run" 12 days ago Up 12 days 1194/udp, 0.0.0.0:1194->1194/tcp openvpn
a273504f9646 mysql:5.6.38 "docker-entrypoint.s…" 8 weeks ago Up 5 days 0.0.0.0:3306->3306/tcp mysql5.6.38
redis容器的id是 a126ec987cfe
5.查看进程
ps -ef|grep redis
[root@localhost~]# ps -ef|grep redis
polkitd 26547 26535 0 14:58 ? 00:00:00 redis-server *:6379
root 26610 26432 0 15:05 pts/0 00:00:00 grep --color=auto redis
6.进入容器执行redis客户端
docker exec -it a126ec987cfe redis-cli -a 'your passwd'
[root@localhost~]# docker exec -it a126ec987cfe redis-cli -h 127.0.0.1 -p 6379 -a 'your passwd'
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d3ebfc7feabc1290
redis_mode:standalone
os:Linux 3.10.0-693.21.1.el7.x86_64 x86_64
...
-h 127.0.0.1 :默认不加为-h 127.0.0.1
-p 6379 :默认不加为 -p 6379
或者连接的时候不带密码,如下:
[root@localhost ~]# docker exec -it a126ec987cfe redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 'your passwd'
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d3ebfc7feabc1290
redis_mode:standalone
os:Linux 3.10.0-693.21.1.el7.x86_64 x86_64
arch_bits:64
来源:https://blog.csdn.net/cookily_liangzai/article/details/80726163
标签:Docker,安装,Redis镜像,密码认证
0
投稿
猜你喜欢
AdSense 通过西联快汇进行人民币支付
2007-10-12 19:02:00
UCHome2.0新增投票功能及其使用技巧介绍
2009-08-31 12:05:00
Linux 和Windows 安装Git 步骤详细介绍
2023-08-25 16:30:58
开源框架 Matrix-Dendrite 搭建聊天服务器的详细过程
2023-06-04 03:18:09
不很厚道或许有用的办法 包装网站关键词
2008-12-20 13:46:00
Exchange 2007 Direct Push Mail功能
2010-02-25 19:01:00
Windows7下Linux双操作系统安装图文教程
2022-12-13 11:36:33
图解VMWare安装Centos 7.3教程
2023-11-03 02:00:48
Windows Server 2008被忽视的十大功能
2010-08-26 18:30:00
WordPress Comment Digg插件发布
2009-04-19 12:31:00
江礼坤:深度剖析网店推广与运营
2009-05-08 09:40:00
坚持更新 让我成功跳出谷歌沙盒
2009-01-10 22:07:00
现象分析:谷歌只抓取指向某域名首个链接
2008-12-12 12:10:00
悼念一篇被杀的软文
2007-11-03 21:06:00
判断PR劫持的目标网站的方法
2008-06-19 13:41:00
浅谈中国个人站长的发展
2008-01-01 15:38:00
个人服务器架设全攻略(13)
2010-04-06 18:43:00
Centos 7 64位桌面版安装图文教程
2023-08-30 15:24:09
linux中expect的介绍与使用示例
2023-03-29 09:15:05
谷歌副总裁:Andorid半年内将推出震撼性内容
2010-05-27 13:05:00