proposals/cli-jar-processing.md
Relevant Issue: #2796
Allow users to containerize arbitrary jar files without having to integrate Jib into java build tools (maven and gradle) or use a .yaml jib cli buildfile.
A standard jar can be containerized in two modes, exploded or packaged.
Achieved by calling jib jar ${JAR_NAME}.jar --target ${TARGET_REGISTRY}
The default mode for containerizing a jar. It will explode a jar into the following layers:
SNAPSHOT. Note that this layer will not be created if Class-Path is not present in the manifest.SNAPSHOT. Note that this layer will not be created if Class-Path is not present in the manifest.MANIFEST.MF.Entrypoint : java -cp /app/dependencies/:/app/explodedJar/ ${MAIN_CLASS}
Achieved by calling jib jar ${JAR_NAME}.jar --target ${TARGET_REGISTRY} --mode packaged.
It will result in the following layers on the container:
Class-Path in jar manifest. Note that this layer will not be created if Class-Path is not present in the manifest.Entrypoint : java -jar ${JAR_NAME}.jar
A Spring-Boot Fat Jar can be containerized in two modes, exploded or packaged.
Achieved by calling jib jar ${JAR_NAME}.jar --target ${TARGET_REGISTRY}
The default mode for containerizing a jar. It will explode a jar according to what is specified in the layers.idx file of the jar, if present, or according to following format:
SNAPSHOT.SNAPSHOT.BOOT-INF/classes/ in the jar and META-INF/.BOOT-INF/classes/ in the jar.Entrypoint : java -cp /app org.springframework.boot.loader.JarLauncher
Achieved by calling jib jar ${JAR_NAME}.jar --target ${TARGET_REGISTRY} --mode packaged
It will containerize the jar as is. However, note that we highly recommend against using packaged mode for containerizing spring-boot fat jars.
Entrypoint: java -jar ${JAR_NAME}.jar
The jar command also provides the option to configure the parameters listed below.
--from The base image to use
--jvm-flags JVM arguments, example: --jvm-flags=-Dmy.property=value,-Xshare:off.
--expose Ports to expose on container, example: --expose=5000,7/udp.
--volumes Directories on container to hold extra volumes, example: --volumes=/var/log,/var/log2.
--environment-variables Environment variables to write into container, example: --environment-variables env1=env_value1,env2=env_value2.
--labels Labels to write into container metadata, example: --labels=label1=value1,label2=value2.
-u, --user The user to run the container as, example: --user=myuser:mygroup.
--image-format Format of container, example --image-format=OCI. Overrides the default (Docker).
--program-args Program arguments for container entrypoint.
--entrypoint Entrypoint for container. Overrides the default entrypoint, example: --entrypoint='custom entrypoint'.
--creation-time The creation time of the container in milliseconds since epoch or iso8601 format. Overrides the default (1970-01-01T00:00:00Z).