Java & Containers: What I Wish I Knew Before I Used It: Elder Moraes Developer Advocate @elderjava
Java & Containers: What I Wish I Knew Before I Used It: Elder Moraes Developer Advocate @elderjava
Java & Containers: What I Wish I Knew Before I Used It: Elder Moraes Developer Advocate @elderjava
Elder Moraes
Developer Advocate
@elderjava
Photo by Andy Li on Unsplash
2 @elderjava
Source: https://www.bricoleurbanism.org/whimsicality/personal-container-management/
3 @elderjava
eldermoraes.com/join
Java Champion
@elderjava
Common Issues when combining
Java & containers
• Long build time
• Hard maintainability
• Resources allocation
5 @elderjava
https://github.com/eldermoraes/java_and_containers
6 @elderjava
How to avoid
7 @elderjava
Mind order for caching
8 @elderjava
Be specific for caching
9 @elderjava
Group units for caching
10 @elderjava
How to get rid of
11 @elderjava
Mind unnecessary dependencies
12 @elderjava
Eliminate package manager cache
13 @elderjava
Choose minimal size images
14 @elderjava
Use optimized tools/frameworks
15 @elderjava
How to stay away from
Hard maintainability
16 @elderjava
Use official images
17 @elderjava
Be specific with tags
18 @elderjava
Reference
https://www.docker.com/blog/intro-guide-to-
dockerfile-best-practices/
19 @elderjava
How to manage
Resources allocation
20 @elderjava
For Java 8u121 and before
Container?
cgroups?
21 @elderjava
For Java 8u121 and before
22 @elderjava
For Java 8u121 and before
https://github.com/fabric8io-images/run-java-sh
23 @elderjava
For Java 8u131 and Java 9
• ParallelGCThreads: helps to limit the cpu usage of a container
24 @elderjava
For Java 8u191 and Java 10
• InitialRAMPercentage: initial percentage of heap allocation
25 @elderjava
For Java 11
• -XshowSettings (Container Metrics): display the system or
container configuration
26 @elderjava
For Java 12 and 13
• jhsdb now can be attached to Java processes running in containers
(JDK-8205992)
27 @elderjava
For Java 14
• JFR Event Streaming: expose JDK Flight Recorder data for
continuous monitoring (easier for observability in clusters)
28 @elderjava
Conclusions
• Yes, Java and containers can get along!
29 @elderjava
developer.redhat.com
30 @elderjava