docker-compose.yaml 547 B

12345678910111213141516171819202122
  1. version: '3'
  2. services:
  3. mysql:
  4. platform: linux/x86_64
  5. image: mysql:5.7
  6. container_name: mysql57
  7. environment:
  8. MYSQL_ROOT_PASSWORD: 123456 # 设置 root 密码
  9. ports:
  10. - "3306:3306" # 映射容器的 3306 端口到主机的 3306 端口
  11. volumes:
  12. - mysql-data:/var/lib/mysql # 持久化数据到本地目录
  13. restart: always # 容器崩溃后自动重启
  14. redis:
  15. image: redis:5.0
  16. ports:
  17. - "6379:6379"
  18. restart: always
  19. volumes:
  20. mysql-data: # 定义数据卷,用于持久化存储