docker部署redis(docker-compose)
1.创建docker-compose.yml文件
version: '3'
services:
redis:
image: redis:4.0.8-alpine
container_name: db-redis
restart: always
ports:
- 6379:6379
networks:
- net_db
volumes:
- ./redis/config:/docker/config
- ./redis/data:/data
command: redis-server /docker/config/redis.conf
networks:
net_db:
external: true
image:从docker仓库直接加载的(本地的镜像需要build构建)
container_name :redis别名
volumes :文件映射
command : 容器内运行conf
2.创建目录
mkdir conf & mkdir redis
3. 创建 redis.conf
a. cd redis
b. mkdir config
c. vim redis.conf
4. redis.conf 内容
#redis的databases数量
databases 32
#redis密码
requirepass 123
5. 启动容器
docker-compose up -d