1.数据库迁移
1
|
将cloud-demo涉及的相关sql导入到Linux上的mysql容器中 |
2.阅读docker-compose.yml文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
version: "3.2" services: nacos: image: nacos/nacos-server:1.4.1 environment: MODE: standalone ports: - "8848:8848" mysql: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: root volumes: - "/tmp/mysql/data:/var/lib/mysql" - "/tmp/mysql/conf/hmy.cnf:/etc/mysql/conf.d/my.cnf" ports: - "3306:3306" userservice: build: ./user-service depends_on: - nacos - mysql ports: - "8081:8081" orderservice: build: ./order-service depends_on: - nacos - mysql ports: - "8080:8080" gateway: build: ./gateway depends_on: - nacos - mysql ports: - "10010:10010" |
3.将项目打包
pom.xml文件
1
2
3
4
5
6
7
8
9
|
< build > < finalName >app</ finalName > < plugins > < plugin > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-maven-plugin</ artifactId > </ plugin > </ plugins > </ build > |
配置文件
# 所有连接mysql的地方都要修改为mysql的容器名称(需要添加端口号)
# 所有连接nacos的地方都要修改为nacos的容器名称(需要添加端口号)
到此这篇关于docker compose运行微服务项目的文章就介绍到这了,更多相关docker compose微服务项目内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://www.cnblogs.com/IsMhhla/p/16611550.html