docker-compose.yml 876 B

123456789101112131415161718192021222324252627282930313233343536
  1. version: '3.8'
  2. services:
  3. app:
  4. image: lcfns:1.0 # 指定已有的应用程序镜像名称和标签
  5. container_name: lcfns-server
  6. volumes:
  7. - lcfns:/go/src/lcfns
  8. ports:
  9. - "8889:8889"
  10. - "8850:8850"
  11. - "9001:9001"
  12. environment:
  13. - DB_HOST=db
  14. - DB_USER=lc
  15. - DB_PASSWORD=root
  16. depends_on:
  17. - db # 表示 app 依赖于 db,即启动 app 之前会先启动 db
  18. restart: on-failure
  19. networks:
  20. - lcfns-net
  21. db:
  22. image: mysql:8 # 指定已有的数据库镜像名称和标签
  23. container_name: lcfns-mysql
  24. environment:
  25. MYSQL_ROOT_PASSWORD: root
  26. MYSQL_DATABASE: lcfns
  27. MYSQL_USER: lc
  28. MYSQL_PASSWORD: root
  29. ports:
  30. - "3306:3306" # 将数据库的 3306 端口映射到宿主机的 3306 端口
  31. networks:
  32. - lcfns-net
  33. networks:
  34. lcfns-net:
  35. volumes:
  36. lcfns: