Skip to content

Commit 6af16c0

Browse files
committed
Let's do some docs
1 parent ef72a0a commit 6af16c0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Java Docker health check app
2+
3+
Docker, since verions 1.12 or so, have a neat feature to run a health check on a container.
4+
5+
#### Great! Let's do it with `curl` or `iwr`
6+
Healt check is a really simple thing to implement. You call a service, and it should `0` if it works and `1` if it does
7+
not. Simple? Sure, even Docker dockumentation will tell you how to do it with HTTP based service using `curl`:
8+
9+
```
10+
HEALTHCHECK --interval=5m --timeout=3s \
11+
CMD curl -f http://localhost/ || exit 1
12+
```
13+
14+
Here, every 5 minutes with a timeout of 3 seconds `localhost` will be called. Using `curl`. On Windows, using IWR, it's
15+
a bit more complicate, but still - it works. It's simple in the end. Right?
16+
17+
So why this lib?
18+
19+
#### The problem with `curl` and `iwr`
20+
1. In Linux images, you need to have curl installed. You can start `FROM` alpine and have a 4MB base image. But guess
21+
what - it doesn't come with `curl` pre-installed. So you need to add `RUN apk --update --no-cache add curl`. Sure,
22+
no sweat, easy to do. That will add a new layer of 2.5MB to the image. And additional headaches of curl and libraries.
23+
2. In Windows images, you need to have PowerShell installed. But recent Nano images will not have it. To save space.
24+
Makes sense, right?
25+
3. If you choose any of the above you loose portability. Different scripts for health-checks depending on the platform.
26+
Sure, no biggie... but what for? You have Java installed already. You had to install it. Or find an image that have Java
27+
since your app will rely on it. Right? Let's use it...
28+
29+
### Here comes the solution
30+
A simple library. <100kb. You run it as a Java command line app. Yes, it has to start up Java... but that is not really
31+
a huge deal nowadays.

0 commit comments

Comments
 (0)