@@ -41,7 +41,7 @@ This repository contains methods to Dockerize Java Projects.
41
41
- docker push rahulvaish/springbootdocker
42
42
<img width =" 810 " alt =" image " src =" https://user-images.githubusercontent.com/689226/210193571-6b418088-5b9c-44ca-962d-369d2b3adf85.png " >
43
43
44
-
44
+ < hr >
45
45
46
46
47
47
- ###### [ SpringBoot Inter Container Communication] ( https://github.com/rahulvaish/Docker-Java/tree/SpringBootContainerIO )
@@ -51,26 +51,25 @@ This repository contains methods to Dockerize Java Projects.
51
51
- Test the service: ** CalculatorServiceClient** container inteacts with ** CalculatorService** container. </br >
52
52
![ image] ( https://user-images.githubusercontent.com/689226/66031356-d82c3200-e520-11e9-9892-3e5cb5456b11.png )
53
53
54
-
54
+ <hr >
55
+
55
56
- ###### [ SpringBoot-MySQL Container Communication] ( https://github.com/rahulvaish/Docker-Java/tree/SpringBootMySQL )
56
57
###### This example illustrates how SpringBoot Docker container communicates with MySQL container. [[ Source Code]] ( https://github.com/rahulvaish/Docker-Java/tree/SpringBootMySQL )
58
+ - Create a private network
59
+ ![ image] ( https://user-images.githubusercontent.com/689226/210200502-13125f24-77f8-4597-88cb-1215c4e16e76.png )
57
60
- Start the MySQL container: </br >
58
- ```
59
- docker run --name mysqlcontainer -d -p 3306:3306 -e MYSQL_DATABASE=dev -e MYSQL_ROOT_PASSWORD=root mysql
60
- ```
61
+ ```
62
+ docker container run --network springbootmysqlntw -- name mysqlcontainer -d -p 3306:3306 -e MYSQL_DATABASE=mysqldb -e MYSQL_ROOT_PASSWORD=root mysql
63
+ ```
61
64
- Create Table & Insert some Data: </br>
62
- ![ image] ( https://user-images.githubusercontent.com/689226/66045139-b8a50180-e540-11e9-964a-08e07d555c77.png )
63
-
64
- - ** Build** & ** Run** SpringBoot Image: </br >
65
- ```
66
- docker build -f Dockerfile -t springbootdockermysqldocker .
67
-
68
- docker run -p 9070:9070 springbootdockermysqldocker
69
-
70
- FYI: On MAC, docker run -p 9070:9070 --link mysqlcontainer:mysqlcontainer springbootdockermysqldocker
71
- ```
72
- - Test the service: </br >
73
- ![ image] ( https://user-images.githubusercontent.com/689226/66045691-daeb4f00-e541-11e9-8d6d-c797604fa387.png )
65
+ <img width="1160" alt="image" src="https://user-images.githubusercontent.com/689226/210198420-c762e7af-7bda-4621-8ee8-0bc7a6fafc6a.png">
66
+ - Build & Start SpringBoot Application (on same private network)
67
+ <b>NOTE:</b> We are not hardcoding DB's IP. Instead using container's name.
68
+ 
69
+ <img width="1691" alt="image" src="https://user-images.githubusercontent.com/689226/210200719-fccf68c6-0388-4ddc-929d-cea1a80b2987.png">
70
+ <img width="750" alt="image" src="https://user-images.githubusercontent.com/689226/210200787-e50b31c0-a789-4983-9f6d-231c956b8f3d.png">
71
+
72
+ <hr>
74
73
75
74
76
75
0 commit comments