jib
jib copied to clipboard
Investigate what to do for `jib:dockerBuild` and `jib:buildTar` for multi-platform image building
The Docker daemon probably won't accept a manifest list (or may require a different archive format).
this looks closely related to issue #2751
Thanks for the info in #2751. That's great!
Just for more clarification:
These two are related, but also largely orthogonal. This issue is about what how to push multi-arch images to a local Docker daemon or create a tar in which format. It's only relevant with the jib:dockerBuild and jib:buildTar the goals, where multi-arch image building is simply not possible.
#2751 is only about how to better record all the information about the built images in multi-arch image building. (Currently, Jib is recording only the information about the manifest list push result). #2751 is independent of which target storage to use (whether a remote registry, local Docker daemon, or tar on a filesystem).
I've just come across this issue. We're looking to add arm64 images to our builds, but doing so breaks local development processes that use jib:dockerBuild.
From our perspective we'd like this to continue working, and since docker doesn't support storing multiple architectures for an image (from what I can see), and images in the local docker instance are almost always there to be run, it would make sense for jib:dockerBuild to pick the native platform of the docker instance. This should probably be accompanied by a warning saying it's only building for a single platform.
At least this way, dockerBuild is still somewhat useful, unlike at the moment where adding platforms renders it useless.
That's a good idea. For now, please use the workaround of having two profiles, e.g., a default prod profile that defines multiple platforms and dev or local that defines only the platform that matches your local environment.
~~Regarding building a tar there should also be an option to build an OCI tar which can store multi-arch images (https://github.com/opencontainers/image-spec/blob/main/image-layout.md).
Similar to docker buildx build --output=type=oci,dest=image.tar ...~~
Sorry, found out that it should already be possible (https://github.com/GoogleContainerTools/jib/pull/2181)
Thanks for the clarification and link @SgtSilvio
This might be a better solution for some than requiring defining a command line property (which I always forget 😏).
jib {
to {
image = "..."
auth {...}
}
from {
image = "openjdk:17-jdk"
}
}
gradle.taskGraph.addTaskExecutionGraphListener {
if (!it.hasTask(":jibDockerBuild")) {
logger.info("JIB: Enabling Multi-Platform Images")
jib.from.platforms {
platform {
os = "linux"
architecture = "arm64"
}
platform {
os = "linux"
architecture = "amd64"
}
}
}
}
The only sticking point is that the param to hasTask (:jibDockerBuild in the above) needs to be the complete path to your jibDockerBuild task. For example, if your task is in a subproject named cli, you'd need :cli:jibDockerBuild, for single module projects :jibDockerBuild works.
This issue is closed but I think it's not resolved (just ran into the issue/error that multi-platform is not supported). I think that @elFarto suggestion:
From our perspective we'd like this to continue working, and since docker doesn't support storing multiple architectures for an image (from what I can see), and images in the local docker instance are almost always there to be run, it would make sense for jib:dockerBuild to pick the native platform of the docker instance.
seems very reasonable.
@ddixit14 this issue is still not fixed....
we still get errors from jib when trying to build (without pushing) multi-platform images
here are the two methods that leads to failure
I get multi-platform image building not supported when pushing to Docker engine or multi-platform image building not supported when building a local tar image when trying to build the image without pushing it.
I don't think this issue should have been closed. As noted above, the problem still persists. It does have a workaround however, so in the meantime please use different maven profiles as recommended previously.
jib-maven-plugin:3.4.3, jib-gradle-plugin:3.4.3 and jib-core:0.27.1 have been released with a fix for this! When building to the local docker daemon, Jib now selects the image with os and architecture matching the local docker environment.