docker compose
version: '3.1'
services:
mysql-db:
# 指定容器的名称
container_name: mysql1
# 指定镜像和版本
image: mysql:8.0
ports:
- "3308:3306"
restart: always
# 容器日志大小配置
logging:
driver: 'json-file'
options:
max-size: '5g'
environment:
# 配置root密码
MYSQL_ROOT_PASSWORD: root
volumes:
# 挂载数据目录
- "./mysql/data:/var/lib/mysql"
# 挂载配置文件目录
- "./mysql/config:/etc/mysql/conf.d"
docker compose up -d