关于docker:Docker-安装-Redis

4次阅读

共计 992 个字符,预计需要花费 3 分钟才能阅读完成。

Docker 装置 Redis

参考资料:Docker hub 里搜寻 Redis

https://hub.docker.com/_/redis

简化版

传文件 redis.conf 到虚拟机 192.168.47.128 的 /root/redis 目录下

scp redis.conf root@192.168.47.128:/root/redis

批改配置 bind 0.0.0.0

启动一个 Docker 容器:

docker run --name myredis -v /root/redis/data:/data -v /root/redis/redis.conf:/usr/local/etc/redis/redis.conf -p 6900:6379 -d redis:latest redis-server /usr/local/etc/redis/redis.conf

具体版

  1. 在 Docker hub 搜寻 Redis 镜像
docker search redis
  1. 拉取 Redis 镜像到本地
docker pull redis
  1. 启动一个 Redis 容器

上面的命令没有裸露对外的端口:docker run --name redis -d redis:tag(不必这一条)

docker run --name redis -p 6800:6379 -d redis:latest
  • redis:latest 示意镜像

查看启动日志

docker logs -t -f 容器 id| 容器名称

  1. 进入容器外部查看
docker exec -it redis bash
  1. 须要批改的配置
bind 0.0.0.0
# 开启 aof 长久化
appendonly yes 
  1. 加载启动配置(这不是最全的命令)
docker run --name myredis -v /root/redis/redis.conf:/usr/local/etc/redis/redis.conf -p 6379:6379 -d redis:latest redis-server /usr/local/etc/redis/redis.conf
  1. 最全的启动 Redis 容器命令
docker run --name myredis -v /root/redis/data:/data -v /root/redis/redis.conf:/usr/local/etc/redis/redis.conf -p 6379:6379 -d redis:latest redis-server /usr/local/etc/redis/redis.conf
正文完
 0