win10 docker部署redis并启动远程连接

  1. 拉取镜像 
    docker pull redis
  2. 准备配置文件 下载配置文件 url为:http://download.redis.io/redis-stable/redis.conf
    .bind 127.0.0.1改为 bind 0.0.0.0或者 # bind 127.0.0.1(注释掉即可)
    Ⅱ.protected-mode no  //关闭保护模式
    Ⅲ.appendonly yes     //持久化
    Ⅳ.requirepass 123456   //密码 
    Ⅵ.maxmemory-policy allkeys-lru   //设置过期淘汰(无需修改)
    ...根据需要修改
  3. 创建容器并映射路径

    docker run -p 6379:6379 --name redis ^
    -v /e/software/redis/docker-redis-config/redis.conf:/etc/redis/redis.conf ^
    -v /e/software/redis/docker-redis-data:/data ^
    -d redis redis-server /etc/redis/redis.conf ^
    --appendonly yes

    1. -p 6379:6379  容器redis 端口6379 映射 宿主机6379

    2. --name redis 容器 名字 为 redis

    3. -v /e/software/redis/docker-redis-config/redis.conf:/etc/redis/redis.conf    容器 /etc/redis/redis.conf 配置文件 映射宿主机 /e/software/redis/docker-redis-config/redis.conf。  会将宿主机的配置文件复制到docker中。

     重要: 配置文件映射,docker镜像redis 默认无配置文件。

    4 --v /e/software/redis/docker-redis-data:/data   容器 /data 映射到宿主机 /e/software/redis/docker-redis-data

    5.-d redis  后台模式启动 redis 

    6. redis-server /etc/redis/redis.conf    redis 将以 /etc/redis/redis.conf 为配置文件启动
    7. --appendonly yes  开启redis 持久化


  4. 查看是否启动成功  docker ps 
    如果成功 使用宿主机连接

     

     重要  重要  重要
    在win上别忘了加路径:

     

     

     

posted @ 2020-09-11 22:58  我忘不掉  阅读(1900)  评论(0编辑  收藏  举报