1 搜索redis镜像
docker search redis
2 下载redis镜像
docker pull redis
3 查看redis镜像
docker images | grep redis
4 创建挂载目录
mkdir -p /docker/redis/etc/redis
mkdir -p /docker/redis/data
5 下载redis的配置文件
/docker/redis/etc/redis
wget http://download.redis.io/redis-stable/redis.conf
6 修改配置
# 将如下修改为0.0.0.0,否则只能本地访问
# bind 127.0.0.1 -::1
bind 0.0.0.0
# 将如下配置修改为yes,允许远程链接
# protected-mode yes
protected-mode no
# 设置密码
# requirepass foobared
requirepass xxxxxxxx
7 创建redis的docker
docker run -p 6379:6379 --name redis-db -v /docker/redis/etc/redis:/etc/redis -v /docker/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
8 查看创建的容器
docker ps |grep redis-db
9 进入容器登录redis
[root@iZbp1flzt6x7pxmxfhmxeeZ redis]# docker exec -it redis-db bash
root@fac9766327fb:/data# redis-cli
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth xxxxxxxx
OK
127.0.0.1:6379>exit
root@fac9766327fb:/data# exit
exit
[root@iZbp1flzt6x7pxmxfhmxeeZ redis]#
1 搜索redis镜像
docker search redis
2 下载redis镜像
docker pull redis
3 查看redis镜像
docker images | grep redis
4 创建挂载目录
mkdir -p /docker/redis/etc/redis
mkdir -p /docker/redis/data
5 下载redis的配置文件
/docker/redis/etc/redis
wget http://download.redis.io/redis-stable/redis.conf
6 修改配置
# 将如下修改为0.0.0.0,否则只能本地访问
# bind 127.0.0.1 -::1
bind 0.0.0.0
# 将如下配置修改为yes,允许远程链接
# protected-mode yes
protected-mode no
# 设置密码
# requirepass foobared
requirepass xxxxxxxx
7 创建redis的docker
docker run -p 6379:6379 --name redis-db -v /docker/redis/etc/redis:/etc/redis -v /docker/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
8 查看创建的容器
docker ps |grep redis-db
9 进入容器登录redis
[root@iZbp1flzt6x7pxmxfhmxeeZ redis]# docker exec -it redis-db bash
root@fac9766327fb:/data# redis-cli
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth xxxxxxxx
OK
127.0.0.1:6379>exit
root@fac9766327fb:/data# exit
exit
[root@iZbp1flzt6x7pxmxfhmxeeZ redis]#