You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/post/dockerize-spring-boot.md
+32-6Lines changed: 32 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ image:
28
28
projects: []
29
29
---
30
30
31
-
#Why?
31
+
## Introduction
32
32
33
33
In this post, I'd like to present a few options to ship a spring boot application in a docker container. There are many easy ways to *dockerize a spring boot* (probably a nice google hit search), but I don't see too much discussion around the pros and cons. So let's jump into it
34
34
@@ -82,7 +82,7 @@ curl http://localhost:8080/ping
82
82
83
83
Our application is ready, so let's create a docker image for it. First let's
@@ -94,20 +94,46 @@ You can build and run the Docker image:
94
94
95
95
```sh
96
96
docker build -t dockerize-spring-boot .
97
-
docker run -it -p 8080:8080 --rm dockerize-spring-boot
97
+
docker run -it -p 8080:8080 --rm $ dockerize-spring-boot
98
98
```
99
99
100
100
Verify that we can reach our REST API within the container as expected:
101
101
102
102
```sh
103
-
curl http://localhost:8080/ping
103
+
$ curl http://localhost:8080/ping
104
104
> Pong!
105
105
```
106
106
107
107
Are we done? - Not at all.
108
108
109
109
### What's the problem?
110
110
111
-
Creating `Dockerfile` manually has it pros and cons. It's the most flexible solution where you control everything. No dependency needed.
111
+
Creating `Dockerfile` manually has its pros and cons. It's the most flexible solution where you control everything. No dependency needed.
112
+
113
+
The problem comes when you need more than a `Hello World` example.
114
+
115
+
#### Repetitive
116
+
117
+
When you have more than 1 java app to dockerize, the number of dockerfiles starts to grow and you have to maintain and update each file independently.
118
+
119
+
#### Efficiency
120
+
121
+
In this simple example, we defined our base image and started our *fat jar*. But is that the most optimal way to build and run a spring boot (or any other java) application?
122
+
For example let's change a single file in our application and build the image again:
0 commit comments