Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate what to do for jib:dockerBuild and jib:buildTar for multi-platform image building #2743

Closed
chanseokoh opened this issue Sep 3, 2020 · 11 comments

Comments

@chanseokoh
Copy link
Member

The Docker daemon probably won't accept a manifest list (or may require a different archive format).

@tom-haines
Copy link

this looks closely related to issue #2751

@chanseokoh
Copy link
Member Author

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).

@elFarto
Copy link

elFarto commented Sep 30, 2021

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.

@chanseokoh
Copy link
Member Author

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.

@SgtSilvio
Copy link

SgtSilvio commented Jun 16, 2022

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 (#2181)

@mpeddada1
Copy link
Contributor

Thanks for the clarification and link @SgtSilvio

@ddixit14 ddixit14 closed this as completed Aug 4, 2022
@kdubb
Copy link

kdubb commented Feb 17, 2023

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.

@woj-tek
Copy link

woj-tek commented Mar 17, 2023

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.

@clembo590
Copy link

@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.

@dangazineu
Copy link

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.

@dangazineu dangazineu reopened this May 14, 2024
@mpeddada1
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants