docker-compose部署项目(redis、mysql)

首先创建局域网命令
docker network create docker_network

version: "3"

管理的服务

services:
redis:
# 指定镜像
image: redis
ports:
# 端口映射
- 16379:6379
volumes:
# 目录映射
- "./redis/conf:/usr/local/etc/redis"
- "./redis/data:/data"
command:
# 执行的命令
redis-server

mysql:
image: mysql:8.0
ports:
- 13306:3306
volumes:
- "./mysql/data:/var/lib/mysql"
- "./mysql/conf.d:/etc/mysql/conf.d"
environment:
# 环境变量
- MYSQL_ROOT_PASSWORD= 123456
network:
default:
external:
name: docker-network

你可能感兴趣的:(docker-compose部署项目(redis、mysql))