zoukankan      html  css  js  c++  java
  • docker安装并运行redis

      拉取镜像:

    [mall@VM_0_7_centos ~]$ sudo docker pull redis:3.2
    [sudo] password for mall: 
    3.2: Pulling from library/redis
    f17d81b4b692: Pull complete 
    b32474098757: Pull complete 
    8980cabe8bc2: Pull complete 
    58af19693e78: Pull complete 
    a977782cf22d: Pull complete 
    9c1e268980b7: Pull complete 
    Digest: sha256:7b0a40301bc1567205e6461c5bf94c38e1e1ad0169709e49132cafc47f6b51f3
    Status: Downloaded newer image for redis:3.2
    docker.io/library/redis:3.2

      docker运行redis:

    [mall@VM_0_7_centos ~]$ sudo docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data -d redis:3.2 redis-server --appendonly yes
    55a9d1906429869ab46db6e889c44b5822f695ec81869f1cfc8f9ed0ddb48ee8

      参数说明:

      -p 6379:6379:端口映射,本地端口6379映射到docker容器端口6379

      --name redis:指定容器名称为redis

      -v /mydata/redis/data:/data:将容器的配置文件夹/data挂在到当前主机/mydata/redis/data

      -d -d redis:3.2 redis-server:以守护进程deamon运行redis服务器

      --appendonly yes:开启AOF模式持久化

      进入docker,使用redis客户端连接服务端:

    [mall@VM_0_7_centos ~]$ sudo docker exec -it redis redis-cli
    [sudo] password for mall: 
    127.0.0.1:6379> set hello world
    OK
    127.0.0.1:6379> get hello
    "world"
    127.0.0.1:6379> 
  • 相关阅读:
    MySQL导出数据库、数据库表结构、存储过程及函数
    个人支付接口
    C# WPF,XAML 跨平台应用框架
    uniapp 第三方组件库
    C语言图形界面库
    微信小程序 获取cookie 以及设置 cookie
    stm32资源网
    找最长连续重复字母子串
    asp .net web api Swagger简单实用
    跨域问题
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/11769867.html
Copyright © 2011-2022 走看看