Jib Core is a Java library for building Docker and OCI container images. It implements a general-purpose container builder that can be used to build containers without a Docker daemon, for any application. The implementation is pure Java.
The API is currently in alpha and may change substantially.
Jib Core powers the popular Jib plugins for Maven and Gradle. The plugins build containers specifically for JVM languages and separate the application into multiple layers to optimize for fast rebuilds.
For the Maven plugin, see the jib-maven-plugin project.
For the Gradle plugin, see the jib-gradle-plugin project.
For information about the Jib project, see the Jib project README.
- Extensions to make building Java and other language-specific containers easier
- Structured events to react to parts of Jib Core's execution
See Milestones for planned features. Get involved with the community for the latest updates.
Add Jib Core as a dependency using Maven:
<dependency>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-core</artifactId>
<version>0.1.0</version>
</dependency>
Add Jib Core as a dependency using Gradle:
dependencies {
compile 'com.google.cloud.tools:jib-core:0.1.0'
}
Jib.from("busybox")
.addLayer(Arrays.asList(Paths.get("helloworld.sh")), AbsoluteUnixPath.get("/"))
.setEntrypoint("sh", "/helloworld.sh")
.containerize(
Containerizer.to(RegistryImage.named("gcr.io/my-project/hello-from-jib")
.addCredential("myusername", "mypassword")));
Jib.from("busybox")
creates a newJibContainerBuilder
configured withbusybox
as the base image..addLayer(...)
configures theJibContainerBuilder
with a new layer withhelloworld.sh
(local file) to be placed into the container at/helloworld.sh
..setEntrypoint("sh", "/helloworld.sh")
sets the entrypoint of the container to run/helloworld.sh
.RegistryImage.named("gcr.io/my-project/hello-from-jib")
creates a newRegistryImage
configured withgcr.io/my-project/hello-from-jib
as the target image to push to..addCredential
adds the username/password credentials to authenticate the push togcr.io/my-project/hello-from-jib
. SeeCredentialRetrieverFactory
for common credential retrievers (to retrieve credentials from Docker config or credential helpers, for example). These credential retrievers an be used with.addCredentialRetriever
.Containerizer.to
creates a newContainerizer
configured to push to theRegistryImage
..containerize
executes the containerization. If successful, the container image will be available atgcr.io/my-project/hello-from-jib
.
None yet available. We welcome contributions for examples and tutorials!
Jib
- the main entrypoint for using Jib Core
JibContainerBuilder
- configures the container to build
Containerizer
- configures how and where to containerize to
JibContainer
- information about the built container
Three TargetImage
types define the 3 different targets Jib can build to:
RegistryImage
- builds to a container registryDockerDaemonImage
- builds to a Docker daemonTarImage
- saves as a tarball archive
Other useful classes:
ImageReference
- represents an image reference and has useful methods for parsing and manipulating image referencesLayerConfiguration
- configures a container layer to buildCredentialRetriever
- implement with custom credential retrieval methods for authenticating against a container registryCredentialRetrieverFactory
- provides usefulCredentialRetriever
s to retrieve credentials from Docker config and credential helpersEventHandlers
- attach event handlers to handle events dispatched during the container build execution
The Jib Core system consists 3 main parts:
- an execution orchestrator that executes an asynchronous pipeline of containerization steps,
- an image manipulator capable of handling Docker and OCI image formats, and
- a registry client that implements the Docker Registry V2 API.
Some other parts of Jib Core internals include:
- a caching mechanism to speed up builds (configurable with
Containerizer.setApplicationLayersCache
andContainerizer.setBaseImageLayersCache
) - an eventing system to react to events from Jib Core during its execution (add handlers with
Containerizer.setEventHandlers
) - support for fully-concurrent multi-threaded executions
See the Jib project README.
See the Jib project FAQ.
See the Jib project README.