[root@localhost conf]# docker search redis
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/redis Redis is an open source key-value store th... 6146 [OK]
docker.io docker.io/bitnami/redis Bitnami Redis Docker Image 97 [OK]
docker.io docker.io/sameersbn/redis 74 [OK]
docker.io docker.io/grokzen/redis-cluster Redis cluster 3.0, 3.2, 4.0 & 5.0 39
docker.io docker.io/hypriot/rpi-redis Raspberry Pi compatible redis image 34
docker.io docker.io/kubeguide/redis-master redis-master with "Hello World!" 27
docker.io docker.io/kubeguide/guestbook-redis-slave Guestbook redis slave 22
docker.io docker.io/redislabs/redis Clustered in-memory database engine compat... 16
docker.io docker.io/rediscommander/redis-commander Alpine image for redis-commander - Redis m... 15 [OK]
docker.io docker.io/arm32v7/redis Redis is an open source key-value store th... 11
docker.io docker.io/webhippie/redis Docker images for redis 9 [OK]
docker.io docker.io/oliver006/redis_exporter Prometheus Exporter for Redis Metrics. Su... 7
docker.io docker.io/rtoma/logspout-redis-logstash Logspout including Redis adapter for sendi... 5
docker.io docker.io/centos/redis-32-centos7 Redis in-memory data structure store, used... 4
docker.io docker.io/arm64v8/redis Redis is an open source key-value store th... 3
docker.io docker.io/frodenas/redis A Docker Image for Redis 2 [OK]
docker.io docker.io/wodby/redis Redis container image with orchestration 2 [OK]
docker.io docker.io/circleci/redis CircleCI images for Redis 1 [OK]
docker.io docker.io/google/guestbook-python-redis A simple guestbook example written in Pyth... 1
docker.io docker.io/kilsoo75/redis-master This image is for the redis master of SK C... 1
docker.io docker.io/tiredofit/redis Redis Server w/ Zabbix monitoring and S6 O... 1 [OK]
docker.io docker.io/anchorfree/redis redis cache server for logging 0
docker.io docker.io/cflondonservices/redis Docker image for running redis 0
docker.io docker.io/iadvize/redis 0
docker.io docker.io/xetamus/redis-resource forked redis-resource 0 [OK]

[root@localhost conf]# docker pull redis:4.0.11
Trying to pull repository docker.io/library/redis ...
4.0.11: Pulling from docker.io/library/redis
a5a6f2f73cd8: Already exists
a6d0f7688756: Pull complete
53e16f6135a5: Pull complete
106da5e40edc: Pull complete
f7cb8ce75c46: Pull complete
059508063f4f: Pull complete
Digest: sha256:ee891094f0bb1a76d11cdca6e33c4fdce5cba1f13234c5896d341f6d741034b1
Status: Downloaded newer image for docker.io/redis:4.0.11

[root@localhost conf]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/redis 4.0.11 a38ee13679d8 10 days ago 83.4 MB
docker.io/mysql 5.7.24 ae6b78bedf88 10 days ago 372 MB

创建目录和配置文件redis.conf(如果不事先创建好redis.conf则docker run的时候会自己创建一个redis.conf目录,无法自动创建配置文件)
mkdir -p /usr/local/redis/conf

cd /usr/local/redis/conf

touch redis.conf

切记redis.conf中注释掉:#daemonize yes 否则无法启动容器

[root@localhost conf]# docker run -p 6379:6379 --name redis4_0_11 --privileged=true -v /usr/local/redis/data:/data -v /usr/local/redis/conf/redis.conf:/etc/redis/redis.conf -d redis:4.0.11 redis-server /etc/redis/redis.conf --requirepass "123456" --appendonly yes
2f7358ea6c6798186058712457ad8670c4c06cd2e1bbe439670c7df28b696d2b

[root@localhost conf]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2f7358ea6c67 redis:4.0.11 "docker-entrypoint..." 4 seconds ago Up 4 seconds 0.0.0.0:6379->6379/tcp redis4_0_11
080d8084681c mysql:5.7.24 "docker-entrypoint..." 4 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql5_7_24

最后创建完后使用Redis Desktop Manager来进行测试,没问题

[root@localhost ~]# docker inspect redis4_0_11|grep -i add
"CapAdd": null,
"GroupAdd": null,
"LinkLocalIPv6Address": "",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"GlobalIPv6Address": "",
"IPAddress": "172.17.0.3",
"MacAddress": "02:42:ac:11:00:03",
"IPAddress": "172.17.0.3",
"GlobalIPv6Address": "",
"MacAddress": "02:42:ac:11:00:03"

[root@localhost ~]# docker exec -it redis4_0_11 redis-cli -h 172.17.0.3

172.17.0.3:6379> get test
(error) NOAUTH Authentication required.
172.17.0.3:6379> get list111
(error) NOAUTH Authentication required.
172.17.0.3:6379> auth 123456
OK
172.17.0.3:6379> get test
"121k2k12k"
172.17.0.3:6379> get list111
(error) WRONGTYPE Operation against a key holding the wrong kind of value
172.17.0.3:6379> lrange list111 1 2
1) "aaa"
172.17.0.3:6379> lrange list111 0 2
1) "bbb"
2) "aaa"

最新文章

  1. 【SQLServer】DBHelper即C#数据库底层封装
  2. SharePoint 2013技巧分享系列 - Active Directory同步显示用户照片
  3. 转:OSGI 实战 Equinox
  4. 如何解决Response.Redirect方法传递汉字丢失或乱码问题?
  5. windows bat 批处理 !vm 合并快播文件
  6. Flash Media Server 4.5 序列号 (fms4.5 激活码)
  7. 优化磁盘I/O
  8. ubuntu下使用反编译apk,工具dex2jar和jd-gui
  9. javascript对象与实例
  10. Host key verification failed解决
  11. 连接Oracle数据库的OracleHelper.cs
  12. leetcode — minimum-path-sum
  13. LeetCode算法题-Sqrt(Java实现)
  14. 【优秀的艺术文字和图标设计软件】Art Text 3.2.3 for Mac
  15. 关于C++中的指针、数组
  16. EXSI中Linux安装tools
  17. 【Python026--字典内键方法】
  18. 深度学习课程笔记(七):模仿学习(imitation learning)
  19. mysql high availability 概述
  20. InstallShield中打包ArcEnineRuntime

热门文章

  1. List批量赋值的几种方法
  2. oracle 11g R2 标准版 64位linux安装
  3. GY89的使用
  4. Java微信公众平台开发(十二)--微信用户信息的获取
  5. 微信小程序中遇到的wx:if问题
  6. vector向量容器
  7. c++ 组合模式(composite)
  8. 银行家算法之JavaScript实现
  9. Debian上SCST的设置
  10. 数据预处理 center&scale&box-cox