SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
v
Java in a World of Containers
Arun Gupta, Principal Technologist, AWS, @arungupta
Bob Vandette, Consulting Engineer, Oracle, @BobVandette
Safe Harbor Statement
The following is intended to outline our general product direction. It
is intended for information purposes only, and may not be
incorporated into any contract. It is not a commitment to deliver any
material, code, or functionality, and should not be relied upon in
making purchasing decisions. The development, release, and timing
of any features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
• Java in a World of Containers
• Creating Docker images
• Creating Custom JREs
• Java + Docker features
Agenda
3
In a World of Containers We Expect…
• Safety and security becoming increasingly more important
• Sprawl
• Many instances
• Mix of different applications
• Heterogeneous machines
• Heterogeneous container configurations
https://citelighter-cards.s3.amazonaws.com/p17k6i1bqs3okg8gnisklkg1k0_51924.png
Java’s characteristics make it ideal for a container environment
5
Java in a World of Containers
• Managed language/runtime
• Hardware and operating system agnostic
• Safety and security enforced by JVM
• Reliable: Compatibility is a key design goal
• Runtime adaptive: JVM ensures stable execution when environment changes
• Rich eco system
Java’s characteristics make it ideal for a container environment
6
Java in a World of Containers
• Managed language/runtime
• Hardware and operating system agnostic
• Safety and security enforced by JVM
• Reliable: Compatibility is a key design goal
• Runtime adaptive: JVM ensures stable execution when environment changes
• Rich eco system
We are committed to keeping Java the first choice for container deployments
How Docker Works for Me
“During Java Platform
development, Docker
helps to increase our
teams productivity by
allowing quick access
to pre-canned images
that we can use to
quickly test new
features on a variety of
configurations.”
Bob Vandette
Oracle Java Products Group
“Help developers learn
good practices for
building containerized
applications. Authoring
books and online
courses. Bragging
rights for being a
#DockerCaptain. ”
Arun Gupta
AWS
v
Creating Docker Images
Docker – Minimum files needed
<dir>/
Dockerfile
jdk-10.0.1_linux-x64_bin.tar.gz
hello/HelloWorld.class
FROM oraclelinux:7-slim
ADD jdk-10.0.1_linux-x64_bin.tar.gz /opt/jdk
ENV PATH=$PATH:/opt/jdk/jdk-10.0.1/bin
COPY hello /hello
CMD [ "java", "-cp", ". ", "-showversion", "HelloWorld" ]
10
Dockerfile contents
# docker image build -t dockercon .
Sending build context to Docker daemon 354.9 MB
Step 1/5 : FROM oraclelinux:7-slim
. . .
Successfully built df05dbf52403
# docker container run --rm dockercon
java version ”10.0.1” 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
Hello, world!
11
Docker image creation and execution
v
Creating Custom Java Runtimes
A Docker image containing the full JDK is large (500+ MB)
• Contains the stuff you want: java.{lang,util,…}.*, javax.management.*, …
• And all the stuff you don’t: corba, jaxws, …
JDK 9 introduces a module system and tooling for creating custom JREs
• Only include the modules/functionality needed for the application
• A minimal JRE only includes the java.base module
• May be enough for many applications
• jdeps can help identify which modules an application uses
jdeps lib/tomcat-api.jar
org.apache.tomcat (tomcat-api.jar)
-> java.base
-> java.instrument
-> java.naming
...
13
Creating Custom JREs
Creating a custom JRE is straightforward
jlink <options>
--module-path <modulepath>
--add-modules <module>[,<module>...]
Example: Creating a java.base (only) JRE
$JAVA_HOME/bin/jlink
--output hello-jre
--module-path $JAVA_HOME/jmods
–-add-modules java.base
hello-jre/bin/java –m helloworld HelloWorld
Note: The application does not have to be module aware!
14
Creating a Custom JRE
Custom JRE
my.module
java.management
java.base
Creation of custom JRE Docker image can be automated using Multi-Stage
Dockerfiles
# Multi-Stage example using jlink to produce small Java runtime
FROM openjdk:10-jdk AS java-build
WORKDIR /jlink/outputdir
RUN jlink --module-path /docker-java-home/jmods --strip-debug --
compress=2 --output java --add-modules java.base
FROM oraclelinux:latest
WORKDIR /root/
COPY --from=java-build /jlink/outputdir .
ENV PATH /root/java/bin:$PATH
CMD ["bash”]
15
Multi-Stage Dockerfile
Full JDK: Default JDK (not jlink:ed)
java.base: jlink --add-modules java.base
“netty”: A set of modules expected to be sufficient
for many/most Java applications
--add-modules java.base,java.logging,
java.management,java.xml,
jdk.management,jdk.unsupported
Note: Does not include the netty application itself
Size can be further optimized
jlink –-compress (can reduce size by 25%+)
16
Optimizing the Size of the JRE
JRE sizes
Size(MB)
0
50
100
150
200
250
300
350
400
450
500
550
600
Full JDK java.base “netty”
6046
568
Base image is a significant part of the total
image size. With Docker the exact base image
matters less
As long as it can still run Java!
Optimizing the Base Image Size
Docker image sizes (java.base)
Size(MB)
0
25
50
75
100
125
150
175
200
225
250
275
300
oraclelinux:7 oraclelinux:7-slim
46
46
118
229 Base image size
java.base
Small. Simple. Secure.
Alpine Linux is a security-
oriented, lightweight Linux
distribution based on musl
libc and busybox.
-
https://www.alpinelinux.org
musl is lightweight, fast, simple, free, and
strives to be correct in the sense of
standards-conformance and safety.
- https://www.musl-libc.org
Alpine Linux & musl libc
• OpenJDK project “Portola” provides a
port of the JDK to Alpine/musl
• The Alpine Linux base image weighs in at
4MB
• Uses the “musl” C library
http://openjdk.java.net/projects/portola
http://hg.openjdk.java.net/portola/portola
portola-dev@openjdk.java.net
Early access binaries: http://jdk.java.net/11
OpenJDK Project “Portola”
Docker base image sizes (java.base)
Size(MB)
0
25
50
75
100
125
150
175
200
225
250
275
300
oraclelinux:7 oraclelinux:7-slim alpinelinux:3.6
46
46
46
4
118
229
• OpenJDK project “Portola” provides a
port of the JDK to Alpine/musl
• The Alpine Linux base image weighs in at
4MB
• Uses the “musl” C library
http://openjdk.java.net/projects/portola
http://hg.openjdk.java.net/portola/portola
portola-dev@openjdk.java.net
Early access binaries: http://jdk.java.net/11
OpenJDK Project “Portola”
Docker base image sizes (java.base)
Size(MB)
0
25
50
75
100
125
150
175
200
225
250
275
300
oraclelinux:7 oraclelinux:7-slim alpinelinux:3.6
46
46
46
4
118
229
Any interest in an Alpine port?
• OpenJDK project “Portola” provides a
port of the JDK to Alpine/musl
• The Alpine Linux base image weighs in at
4MB
• Uses the “musl” C library
http://openjdk.java.net/projects/portola
http://hg.openjdk.java.net/portola/portola
portola-dev@openjdk.java.net
Early access binaries: http://jdk.java.net/11
OpenJDK Project “Portola”
Docker base image sizes (java.base)
Size(MB)
0
25
50
75
100
125
150
175
200
225
250
275
300
oraclelinux:7 oraclelinux:7-slim alpinelinux:3.6
46
46
46
4
118
229
Any interest in helping to maintain it?
v
Java and Docker Features
• Micro-services and Docker encourages running many
processes on the same machine
• Chances are many instances will be running the
exact same application
• OS shared libraries allows for sharing native data
• libc, libjvm.so all get shared automatically by the OS
& Docker (Assuming same layer/file/inode)
• What about Java class data?
23
Sharing Across Container Instances
• Like OS shared libraries for
Java class data
• Archive is memory-mapped
• RO pages shared, RW
pages are shared copy-on-
write
• Classes read from mapped
memory without overhead
of searching, reading &
parsing from JAR files
• Archive can be shared
across Docker containers
24
Class Data Sharing (CDS / APPCDS)
Example: WebLogic Server Base Domain
25
AppCDS Benefits - Startup Time and Footprint
• Sharing & savings increases with every instance
• Two level archiving is under development
Footprint
Size(MB)-Note:Logarithmic!
1
10
100
1000
10000
Unique Shared Total
4,137
66
4,073 4,652
20
4,634 No AppCDS
AppCDS
Startup Time
Time(s)
0
1
2
3
4
5
6
7
8
9
10
11
12
No AppCDS AppCDS
7.7
11.4
Like AppCDS, but for JIT
compiled code
• Pre-compiled code stored to archive
(shared library)
• Allows sharing, and reduced startup
• Use the new “jaotc” tool to generate an
app specific AOT library
26
Experimental: Ahead-of-Time Compilation
libaot.so
Java ContainerJava Container
Pre-compiled Java
methods
The JVM has plenty of ergonomics which are based on the underlying system
• Memory, #cpus, exact CPU model, etc.
• For example, heap size is based on available memory
Docker allows for specifying resource limits
• Implemented through cgroups
• Not transparent - requires cooperative application support
• Explicit support needed for JVM
27
Honoring Docker/cgroups Resource Limits
Reflected in
• Runtime.availableProcessors(), ForkJoin pool, VM internal thread pools
• Libraries/frameworks such as core.async, ElasticSearch, Netty
28
Honoring Docker/cgroups Resource Limits: CPU
The JDK honors Docker CPU settings
1. --cpuset-cpus (JDK 9)
2. --cpus or --cpu-quota, --cpu-period (JDK 10)
3. --cpu-shares
Selects physical CPUs to be used by container
Limits the amount of CPU time per period
Provides a relative priority over other containers
29
Available Processor Selection Algorithm
Java computes the number of active processors at startup in order to report the Runtime.availableProcessors() and make
decisions on the number of GC and Compiler threads.
If you don’t like our choice use –XX:ActiveProcessorCount=xx
The algorithm (updated in JDK 11) depends on state of –XX:PreferContainerQuotaForCPUCount
(default: true)
True: Active processor count = min(cpuset count, --cpu-quota/--cpu-period)
OR
False: Active processor count = min(cpuset count, min(--cpu-quota/--cpu-period, --cpu-shares/1024))
Memory settings (JDK 10)
• docker --memory=<size>
• Affects the Java ergonomic policy which selects size for …
• Java heap size, GC region sizes, other VM internal structures like code cache, …
JDK-8186248: (JDK 10) Allow more flexibility in selecting Heap % of available RAM
-XX:InitialRAMPercentage
-XX:MaxRAMPercentage
-XX:MinRAMPercentage
30
Honoring Docker/cgroups
Resource Limits: Memory
https://mjg123.github.io/2018/01/10/Java-in-containers-jdk10.html
For more information check out Matthew Gillards blog …
Use “java –Xlog:os+container=trace” to get a dump of the resource limits in effect
JDK-8179498: attach in linux should be relative to /proc/pid/root and
namespace aware (JDK 10)
JDK-8193710: jcmd -l and jps commands do not list Java processes running in
Docker containers (JDK 11)
More to come…
• JDK-8203357: (JDK 11) RFE: Container Metrics
• JDK-8203359: Java Flight Recorder (JFR) improvements for containers
• JDK-8199944: Add Container MBean to JMX
• JDK-8198715: Investigate adding NUMA container support to hotspot
31
Other Java Improvements for Docker
v
QUESTIONS?

Contenu connexe

Tendances

Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Arun Gupta
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux ContainerBalaji Rajan
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerJérôme Petazzoni
 
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and moreAll Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and moreAll Things Open
 
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2daysUsing Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2daysCarlos Sanchez
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...dotCloud
 
Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016Patrick Chanezon
 
Docker for Java Developers - Fabiane Nardon and Arun gupta
Docker for Java Developers - Fabiane Nardon and Arun guptaDocker for Java Developers - Fabiane Nardon and Arun gupta
Docker for Java Developers - Fabiane Nardon and Arun guptaDocker, Inc.
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerGuido Schmutz
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To RunningGiacomo Vacca
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionHao Fan
 
Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...
Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...
Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...Initcron Systems Private Limited
 
Optimizing Docker Images
Optimizing Docker ImagesOptimizing Docker Images
Optimizing Docker ImagesBrian DeHamer
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQdotCloud
 
Weblogic 12c on docker
Weblogic 12c on dockerWeblogic 12c on docker
Weblogic 12c on dockerCK Rai
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developerWeerayut Hongsa
 

Tendances (20)

Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and moreAll Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
 
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2daysUsing Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
 
Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016
 
Docker for Java Developers - Fabiane Nardon and Arun gupta
Docker for Java Developers - Fabiane Nardon and Arun guptaDocker for Java Developers - Fabiane Nardon and Arun gupta
Docker for Java Developers - Fabiane Nardon and Arun gupta
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To Running
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...
Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...
Run it like Google - Story of Devops and Kubernetes Evolution - Past, Present...
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Optimizing Docker Images
Optimizing Docker ImagesOptimizing Docker Images
Optimizing Docker Images
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
Introduction To Docker
Introduction To DockerIntroduction To Docker
Introduction To Docker
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
 
Weblogic 12c on docker
Weblogic 12c on dockerWeblogic 12c on docker
Weblogic 12c on docker
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developer
 

Similaire à Java in a World of Containers - DockerCon 2018

Webinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java AppsWebinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java AppsCodefresh
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containersRed Hat Developers
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDocker, Inc.
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10Arto Santala
 
Introduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud RunIntroduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud RunSaiyam Pathak
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Dockernklmish
 
Vagrant or docker for java dev environment
Vagrant or docker for java dev environmentVagrant or docker for java dev environment
Vagrant or docker for java dev environmentOrest Ivasiv
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best PracticesDavid Delabassee
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxMurugesh33
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxMurugesh33
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline Docker, Inc.
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBlueData, Inc.
 
Introducción a contenedores Docker
Introducción a contenedores DockerIntroducción a contenedores Docker
Introducción a contenedores DockerSoftware Guru
 
Eclipse MicroProfile 과 Microservice Java framework – Helidon
Eclipse MicroProfile 과 Microservice Java framework – HelidonEclipse MicroProfile 과 Microservice Java framework – Helidon
Eclipse MicroProfile 과 Microservice Java framework – HelidonOracle Korea
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouJ On The Beach
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...Eric Smalling
 

Similaire à Java in a World of Containers - DockerCon 2018 (20)

Webinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java AppsWebinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java Apps
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
Introduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud RunIntroduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud Run
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
 
Vagrant or docker for java dev environment
Vagrant or docker for java dev environmentVagrant or docker for java dev environment
Vagrant or docker for java dev environment
 
Docker
DockerDocker
Docker
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best Practices
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker Containers
 
Introducción a contenedores Docker
Introducción a contenedores DockerIntroducción a contenedores Docker
Introducción a contenedores Docker
 
Eclipse MicroProfile 과 Microservice Java framework – Helidon
Eclipse MicroProfile 과 Microservice Java framework – HelidonEclipse MicroProfile 과 Microservice Java framework – Helidon
Eclipse MicroProfile 과 Microservice Java framework – Helidon
 
Java Cloud and Container Ready
Java Cloud and Container ReadyJava Cloud and Container Ready
Java Cloud and Container Ready
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camou
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
.NET RDF APIs
.NET RDF APIs.NET RDF APIs
.NET RDF APIs
 

Plus de Arun Gupta

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdfArun Gupta
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Arun Gupta
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesArun Gupta
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerArun Gupta
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Arun Gupta
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open SourceArun Gupta
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using KubernetesArun Gupta
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native ApplicationsArun Gupta
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with KubernetesArun Gupta
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMArun Gupta
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteArun Gupta
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Arun Gupta
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitArun Gupta
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!Arun Gupta
 
NoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern SuccessNoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern SuccessArun Gupta
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Arun Gupta
 
How to run your first marathon ? JavaOne 2014 Ignite
How to run your first marathon ? JavaOne 2014 IgniteHow to run your first marathon ? JavaOne 2014 Ignite
How to run your first marathon ? JavaOne 2014 IgniteArun Gupta
 
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014Arun Gupta
 
50 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014Arun Gupta
 
Teaching kids how to program
Teaching kids how to programTeaching kids how to program
Teaching kids how to programArun Gupta
 

Plus de Arun Gupta (20)

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using Firecracker
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open Source
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using Kubernetes
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native Applications
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with Kubernetes
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAM
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 Keynote
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv Summit
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!
 
NoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern SuccessNoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern Success
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
 
How to run your first marathon ? JavaOne 2014 Ignite
How to run your first marathon ? JavaOne 2014 IgniteHow to run your first marathon ? JavaOne 2014 Ignite
How to run your first marathon ? JavaOne 2014 Ignite
 
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
 
50 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014
 
Teaching kids how to program
Teaching kids how to programTeaching kids how to program
Teaching kids how to program
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Java in a World of Containers - DockerCon 2018

  • 1. v Java in a World of Containers Arun Gupta, Principal Technologist, AWS, @arungupta Bob Vandette, Consulting Engineer, Oracle, @BobVandette
  • 2. Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 3. • Java in a World of Containers • Creating Docker images • Creating Custom JREs • Java + Docker features Agenda 3
  • 4. In a World of Containers We Expect… • Safety and security becoming increasingly more important • Sprawl • Many instances • Mix of different applications • Heterogeneous machines • Heterogeneous container configurations https://citelighter-cards.s3.amazonaws.com/p17k6i1bqs3okg8gnisklkg1k0_51924.png
  • 5. Java’s characteristics make it ideal for a container environment 5 Java in a World of Containers • Managed language/runtime • Hardware and operating system agnostic • Safety and security enforced by JVM • Reliable: Compatibility is a key design goal • Runtime adaptive: JVM ensures stable execution when environment changes • Rich eco system
  • 6. Java’s characteristics make it ideal for a container environment 6 Java in a World of Containers • Managed language/runtime • Hardware and operating system agnostic • Safety and security enforced by JVM • Reliable: Compatibility is a key design goal • Runtime adaptive: JVM ensures stable execution when environment changes • Rich eco system We are committed to keeping Java the first choice for container deployments
  • 7. How Docker Works for Me “During Java Platform development, Docker helps to increase our teams productivity by allowing quick access to pre-canned images that we can use to quickly test new features on a variety of configurations.” Bob Vandette Oracle Java Products Group “Help developers learn good practices for building containerized applications. Authoring books and online courses. Bragging rights for being a #DockerCaptain. ” Arun Gupta AWS
  • 9. Docker – Minimum files needed <dir>/ Dockerfile jdk-10.0.1_linux-x64_bin.tar.gz hello/HelloWorld.class
  • 10. FROM oraclelinux:7-slim ADD jdk-10.0.1_linux-x64_bin.tar.gz /opt/jdk ENV PATH=$PATH:/opt/jdk/jdk-10.0.1/bin COPY hello /hello CMD [ "java", "-cp", ". ", "-showversion", "HelloWorld" ] 10 Dockerfile contents
  • 11. # docker image build -t dockercon . Sending build context to Docker daemon 354.9 MB Step 1/5 : FROM oraclelinux:7-slim . . . Successfully built df05dbf52403 # docker container run --rm dockercon java version ”10.0.1” 2018-04-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode) Hello, world! 11 Docker image creation and execution
  • 13. A Docker image containing the full JDK is large (500+ MB) • Contains the stuff you want: java.{lang,util,…}.*, javax.management.*, … • And all the stuff you don’t: corba, jaxws, … JDK 9 introduces a module system and tooling for creating custom JREs • Only include the modules/functionality needed for the application • A minimal JRE only includes the java.base module • May be enough for many applications • jdeps can help identify which modules an application uses jdeps lib/tomcat-api.jar org.apache.tomcat (tomcat-api.jar) -> java.base -> java.instrument -> java.naming ... 13 Creating Custom JREs
  • 14. Creating a custom JRE is straightforward jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...] Example: Creating a java.base (only) JRE $JAVA_HOME/bin/jlink --output hello-jre --module-path $JAVA_HOME/jmods –-add-modules java.base hello-jre/bin/java –m helloworld HelloWorld Note: The application does not have to be module aware! 14 Creating a Custom JRE Custom JRE my.module java.management java.base
  • 15. Creation of custom JRE Docker image can be automated using Multi-Stage Dockerfiles # Multi-Stage example using jlink to produce small Java runtime FROM openjdk:10-jdk AS java-build WORKDIR /jlink/outputdir RUN jlink --module-path /docker-java-home/jmods --strip-debug -- compress=2 --output java --add-modules java.base FROM oraclelinux:latest WORKDIR /root/ COPY --from=java-build /jlink/outputdir . ENV PATH /root/java/bin:$PATH CMD ["bash”] 15 Multi-Stage Dockerfile
  • 16. Full JDK: Default JDK (not jlink:ed) java.base: jlink --add-modules java.base “netty”: A set of modules expected to be sufficient for many/most Java applications --add-modules java.base,java.logging, java.management,java.xml, jdk.management,jdk.unsupported Note: Does not include the netty application itself Size can be further optimized jlink –-compress (can reduce size by 25%+) 16 Optimizing the Size of the JRE JRE sizes Size(MB) 0 50 100 150 200 250 300 350 400 450 500 550 600 Full JDK java.base “netty” 6046 568
  • 17. Base image is a significant part of the total image size. With Docker the exact base image matters less As long as it can still run Java! Optimizing the Base Image Size Docker image sizes (java.base) Size(MB) 0 25 50 75 100 125 150 175 200 225 250 275 300 oraclelinux:7 oraclelinux:7-slim 46 46 118 229 Base image size java.base
  • 18. Small. Simple. Secure. Alpine Linux is a security- oriented, lightweight Linux distribution based on musl libc and busybox. - https://www.alpinelinux.org musl is lightweight, fast, simple, free, and strives to be correct in the sense of standards-conformance and safety. - https://www.musl-libc.org Alpine Linux & musl libc
  • 19. • OpenJDK project “Portola” provides a port of the JDK to Alpine/musl • The Alpine Linux base image weighs in at 4MB • Uses the “musl” C library http://openjdk.java.net/projects/portola http://hg.openjdk.java.net/portola/portola portola-dev@openjdk.java.net Early access binaries: http://jdk.java.net/11 OpenJDK Project “Portola” Docker base image sizes (java.base) Size(MB) 0 25 50 75 100 125 150 175 200 225 250 275 300 oraclelinux:7 oraclelinux:7-slim alpinelinux:3.6 46 46 46 4 118 229
  • 20. • OpenJDK project “Portola” provides a port of the JDK to Alpine/musl • The Alpine Linux base image weighs in at 4MB • Uses the “musl” C library http://openjdk.java.net/projects/portola http://hg.openjdk.java.net/portola/portola portola-dev@openjdk.java.net Early access binaries: http://jdk.java.net/11 OpenJDK Project “Portola” Docker base image sizes (java.base) Size(MB) 0 25 50 75 100 125 150 175 200 225 250 275 300 oraclelinux:7 oraclelinux:7-slim alpinelinux:3.6 46 46 46 4 118 229 Any interest in an Alpine port?
  • 21. • OpenJDK project “Portola” provides a port of the JDK to Alpine/musl • The Alpine Linux base image weighs in at 4MB • Uses the “musl” C library http://openjdk.java.net/projects/portola http://hg.openjdk.java.net/portola/portola portola-dev@openjdk.java.net Early access binaries: http://jdk.java.net/11 OpenJDK Project “Portola” Docker base image sizes (java.base) Size(MB) 0 25 50 75 100 125 150 175 200 225 250 275 300 oraclelinux:7 oraclelinux:7-slim alpinelinux:3.6 46 46 46 4 118 229 Any interest in helping to maintain it?
  • 22. v Java and Docker Features
  • 23. • Micro-services and Docker encourages running many processes on the same machine • Chances are many instances will be running the exact same application • OS shared libraries allows for sharing native data • libc, libjvm.so all get shared automatically by the OS & Docker (Assuming same layer/file/inode) • What about Java class data? 23 Sharing Across Container Instances
  • 24. • Like OS shared libraries for Java class data • Archive is memory-mapped • RO pages shared, RW pages are shared copy-on- write • Classes read from mapped memory without overhead of searching, reading & parsing from JAR files • Archive can be shared across Docker containers 24 Class Data Sharing (CDS / APPCDS)
  • 25. Example: WebLogic Server Base Domain 25 AppCDS Benefits - Startup Time and Footprint • Sharing & savings increases with every instance • Two level archiving is under development Footprint Size(MB)-Note:Logarithmic! 1 10 100 1000 10000 Unique Shared Total 4,137 66 4,073 4,652 20 4,634 No AppCDS AppCDS Startup Time Time(s) 0 1 2 3 4 5 6 7 8 9 10 11 12 No AppCDS AppCDS 7.7 11.4
  • 26. Like AppCDS, but for JIT compiled code • Pre-compiled code stored to archive (shared library) • Allows sharing, and reduced startup • Use the new “jaotc” tool to generate an app specific AOT library 26 Experimental: Ahead-of-Time Compilation libaot.so Java ContainerJava Container Pre-compiled Java methods
  • 27. The JVM has plenty of ergonomics which are based on the underlying system • Memory, #cpus, exact CPU model, etc. • For example, heap size is based on available memory Docker allows for specifying resource limits • Implemented through cgroups • Not transparent - requires cooperative application support • Explicit support needed for JVM 27 Honoring Docker/cgroups Resource Limits
  • 28. Reflected in • Runtime.availableProcessors(), ForkJoin pool, VM internal thread pools • Libraries/frameworks such as core.async, ElasticSearch, Netty 28 Honoring Docker/cgroups Resource Limits: CPU The JDK honors Docker CPU settings 1. --cpuset-cpus (JDK 9) 2. --cpus or --cpu-quota, --cpu-period (JDK 10) 3. --cpu-shares Selects physical CPUs to be used by container Limits the amount of CPU time per period Provides a relative priority over other containers
  • 29. 29 Available Processor Selection Algorithm Java computes the number of active processors at startup in order to report the Runtime.availableProcessors() and make decisions on the number of GC and Compiler threads. If you don’t like our choice use –XX:ActiveProcessorCount=xx The algorithm (updated in JDK 11) depends on state of –XX:PreferContainerQuotaForCPUCount (default: true) True: Active processor count = min(cpuset count, --cpu-quota/--cpu-period) OR False: Active processor count = min(cpuset count, min(--cpu-quota/--cpu-period, --cpu-shares/1024))
  • 30. Memory settings (JDK 10) • docker --memory=<size> • Affects the Java ergonomic policy which selects size for … • Java heap size, GC region sizes, other VM internal structures like code cache, … JDK-8186248: (JDK 10) Allow more flexibility in selecting Heap % of available RAM -XX:InitialRAMPercentage -XX:MaxRAMPercentage -XX:MinRAMPercentage 30 Honoring Docker/cgroups Resource Limits: Memory https://mjg123.github.io/2018/01/10/Java-in-containers-jdk10.html For more information check out Matthew Gillards blog … Use “java –Xlog:os+container=trace” to get a dump of the resource limits in effect
  • 31. JDK-8179498: attach in linux should be relative to /proc/pid/root and namespace aware (JDK 10) JDK-8193710: jcmd -l and jps commands do not list Java processes running in Docker containers (JDK 11) More to come… • JDK-8203357: (JDK 11) RFE: Container Metrics • JDK-8203359: Java Flight Recorder (JFR) improvements for containers • JDK-8199944: Add Container MBean to JMX • JDK-8198715: Investigate adding NUMA container support to hotspot 31 Other Java Improvements for Docker