Docker安装Redis。之前直接在Centos手工安装过,现在在Docker下实践一次。
环境说明:
[root@localhost ~]# uname -a
Linux localhost 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
拉取镜像
[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker pull redis:5.0.7
5.0.7: Pulling from library/redis
68ced04f60ab: Already exists
7ecc253967df: Pull complete
765957bf98d4: Pull complete
52f16772e1ca: Pull complete
2e43ba99c3f3: Pull complete
d95576c71392: Pull complete
Digest: sha256:938ee5bfba605cc85f9f52ff95024e9a24cf5511ba6f1cbc68ec9d91a0432125
Status: Downloaded newer image for redis:5.0.7
docker.io/library/redis:5.0.7
[root@localhost ~]# docker run -itd --name redis-test -p 6379:6379 redis:5.0.7
1cc7671fb48a89f432f544acb436f33de205f73934c65dd569a5baf2a6809f78
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cc7671fb48a redis:5.0.7 "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:6379->6379/tcp redis-test
进入redis-cli进行测试
[root@localhost ~]# docker exec -it redis-test /bin/bash
root@1cc7671fb48a:/data# redis-cli
127.0.0.1:6379> set test 1;
OK
127.0.0.1:6379> set test 2;
OK
127.0.0.1:6379>
安装成功,比自己手工一步步安装方便很多,方便快速搭建环境学习。