docker安装redis:
1.拉取镜像
(base) zhuhau@zhuhua:~$ sudo docker pull redis
Using default tag: latest
latest: Pulling from library/redis
68ced04f60ab: Pull complete
7ecc253967df: Pull complete
765957bf98d4: Pull complete
52f16772e1ca: Pull complete
2e43ba99c3f3: Pull complete
d95576c71392: Pull complete
Digest: sha256:6b9920bdc913ebeeed5cd5327decabe9fa829de425b52b3f28a7215ee7c7c457
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
- 运行容器:
(base) zhuhau@zhuhua:~$ sudo docker run -itd --name redis-test -p 6379:6379 redis
5b9519b7e77d21f0031899ae82ca9ea9127f77d3f29b59eab6fe28aec3e32801
- 启动redis服务:
(base) zhuhau@zhuhua:~$ sudo docker exec -it redis-test /bin/bash
root@5b9519b7e77d:/data# redis-cli
127.0.0.1:6379> set test 1
OK
127.0.0.1:6379>