12345678910111213141516171819202122 |
- version: '3'
- services:
- mysql:
- platform: linux/x86_64
- image: mysql:5.7
- container_name: mysql57
- environment:
- MYSQL_ROOT_PASSWORD: 123456 # 设置 root 密码
- ports:
- - "3306:3306" # 映射容器的 3306 端口到主机的 3306 端口
- volumes:
- - mysql-data:/var/lib/mysql # 持久化数据到本地目录
- restart: always # 容器崩溃后自动重启
- redis:
- image: redis:5.0
- ports:
- - "6379:6379"
- restart: always
- volumes:
- mysql-data: # 定义数据卷,用于持久化存储
|