- 终端输入命令,等待下载成功
docker pull images redis:latest
- 查看本地是否下载成功
- 启动redis容器
docker run -itd --name redis-dev -p 6379:6379 redis
--name:随便起个名字,比如redis-dev
-p 6379:6379:映射容器服务的6379端口到宿主机的 6379端口。外部可以直接通过宿主机ip:6379 访问到 Redis 的服务;
redis: 本地镜像的名字
- 查看运行信息
benjie@benjiedeMBP ~ % docker run -itd --name redis-dev -p 6379:6379 redis
ec5f72d8d3a585b40e347fd8f4d00df90526e68022a18f9abcda62de393fd199
benjie@benjiedeMBP ~ % docker ps |grep redis
ec5f72d8d3a5 redis "docker-entrypoint.s…" 11 seconds ago Up 10 seconds 0.0.0.0:6379->6379/tcp redis-dev
benjie@benjiedeMBP ~ %
- 简单操作redis
benjie@benjiedeMBP ~ % docker exec -it redis-dev sh
# redis-cli
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> set age 14
OK
127.0.0.1:6379> get age
"14"
127.0.0.1:6379> quit
#
当然,如果不想敲命令的话,直接在docker软件中启动redis也可以
标签:0.1,benjiedeMBP,redis,dev,6379,mac,m1,docker From: https://www.cnblogs.com/benjieqiang/p/17434183.html