redis 部署
redis docker 环境部署
1.方式一, docker run
docker run --rm -p 6379:6379
-v /home/qtimes/workspace/docker_space/redis_space/data/redis/redis.conf:/etc/redis/redis.conf
-v /home/qtimes/workspace/docker_space/redis_space/data/redis/data:/data
redis:latest
redis-server /etc/redis/redis.conf --appendonly yes
--appendonly yes :开启持久化
--privileged=true :容器内的root拥有真正root权限,否则容器内root只是外部普通用户权限
-v /docker/redis/conf/redis.conf:/etc/redis/redis.conf :映射配置文件
-v /docker/redis/data:/data :映射数据目录
redis-server /etc/redis/redis.conf :指定配置文件启动redis-server进程
-t :让docker分配一个伪终端并绑定到容器的标准输入上,
-i :则让容器的标准输入保持打开.
2.方式一, docker-compose
vim docker-compose.yml
services:
redis:
container_name: 'myredis'
image: 'redis'
#restart: always
ports:
- 6379:6379
command: redis-server --requirepass mypassword
docker-compose up
redis 客户端连接 , *注意连接时无需输入用户名*
[docker 验证]
[idea explorer]