一、前提条件
mac已经安装docker
二、安装步骤如下:
1、拉取镜像命令: docker pull redis
sing default tag: latest
latest: Pulling from library/redis
8559a31e96f4: Pull complete
85a6a5c53ff0: Pull complete
b69876b7abed: Pull complete
a72d84b9df6a: Pull complete
5ce7b314b19c: Pull complete
04c4bfb0b023: Pull complete
Digest: sha256:800f2587bf3376cb01e6307afe599ddce9439deafbd4fb8562829da96085c9c5
Status: Downloaded newer image for redis:latest
2、查看镜像命令:docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 235592615444 3 weeks ago 104MB
nginx latest 4733136e5c3c 10 months ago
3、运行容器命令:docker run -itd --name redis-test -p 6379:6379 redis
4、查看容器运行信息:docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
471e5a8b57ef redis "docker-entrypoint.s…" 6 hours ago Up 45 seconds 0.0.0.0:6379->6379/tcp redis-test
5、连接redis,测试
docker exec -it 471e5a8b57ef /bin/bash
# 471e5a8b57ef为容器ID
root@471e5a8b57ef:/data#
#登录docker成功
执行命令:redis-cli
127.0.0.1:6379> set hello world
OK
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379>