GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.58k stars 1.43k forks source link

Unrecognized field "LayerSources" with Docker 25.0.0 and from image "docker://" #4171

Closed derkoe closed 7 months ago

derkoe commented 7 months ago

Environment:

Description of the issue: Jib error on Docker 25.0.0. with <from><image>docker://eclipse-temurin:8-jre</image></from>:

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.4.0:dockerBuild (default-cli) on project spring-boot-k8s-example: Unrecognized field "LayerSources" (class com.google.cloud.tools.jib.docker.json.DockerManifestEntryTemplate), not marked as ignorable (3 known properties: "Config", "RepoTags", "Layers"])
[ERROR]  at [Source: (sun.nio.ch.ChannelInputStream); line: 1, column: 556] (through reference chain: java.lang.Object[][0]->com.google.cloud.tools.jib.docker.json.DockerManifestEntryTemplate["LayerSources"])

Expected behavior:

Docker daemon as source should work with Docker version 25.0.0

Steps to reproduce:

  1. Install Docker CE 25.0.0 and run the daemon
  2. Clone the Jib Git repository: https://github.com/GoogleContainerTools/jib
  3. cd examples/spring-boot
  4. Add the following configuration to Jib configuration in the pom.xml:
        <from>
            <image>docker://eclipse-temurin:8-jre</image>
        </from>
    1. Pull the Docker base image: docker pull eclipse-temurin:8-jre
    2. Run ./mvnw package jib:dockerBuild

jib-maven-plugin Configuration:

            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                        <from>
                                <image>docker://eclipse-temurin:8-jre</image>
                        </from>
                </configuration>
            </plugin>

Log output:

[INFO] --- jib-maven-plugin:3.4.0:dockerBuild (default-cli) @ spring-boot-k8s-example ---
[INFO] Tagging image with generated image reference spring-boot-k8s-example:0.1.0. If you'd like to specify a different tag, you can set the <to><image> parameter in your pom.xml, or use the -Dimage=<MY IMAGE> commandline flag.
[WARNING] 'mainClass' configured in 'maven-jar-plugin' is not a valid Java class: ${start-class}
[INFO]
[INFO] Containerizing application to Docker daemon as spring-boot-k8s-example:0.1.0...
[WARNING] Base image 'eclipse-temurin:8-jre' does not use a specific image digest - build may not be reproducible
[INFO] Executing tasks:
[INFO] [===========                   ] 37.5% complete
[INFO] > processing base image eclipse-temurin:8-jre
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.660 s
[INFO] Finished at: 2024-01-22T09:32:47Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.4.0:dockerBuild (default-cli) on project spring-boot-k8s-example: Unrecognized field "LayerSources" (class com.google.cloud.tools.jib.docker.json.DockerManifestEntryTemplate), not marked as ignorable (3 known properties: "Config", "RepoTags", "Layers"])
[ERROR]  at [Source: (sun.nio.ch.ChannelInputStream); line: 1, column: 556] (through reference chain: java.lang.Object[][0]->com.google.cloud.tools.jib.docker.json.DockerManifestEntryTemplate["LayerSources"])

Additional Information: Only happens with Docker 25.0.0 - no issues with older versions of Docker.

chanseokoh commented 7 months ago

Sounds like Jib needs to fix this to support newer Docker versions. In that case, #4172 should do it.

mpeddada1 commented 7 months ago

@derkoe @chanseokoh Thanks for starting this discussion! To better understand the issue, it looks like Jib is return an error when the manifest contains the LayerSources field. I'm curious about where this extra field is coming from. Does this happen regardless of which base image you use? Additionally, I wasn't able to find references to it in the official docs but perhaps you may more context for this.

chanseokoh commented 7 months ago

@mpeddada1 I have no context about this. Just guessing from @derkoe's comments, the latest Docker may have this field, at least in some cases. But I thought it wouldn't hurt to allow extra fields anyway. @derkoe should answer these.

derkoe commented 7 months ago

@mpeddada1 it happens with any image I've tried so far.

mpeddada1 commented 7 months ago

Thank you both for the follow-up. Hm @derkoe that is interesting. Are Docker 25 built images always including this field in the manifest now?

derkoe commented 7 months ago

I am not talking about images built with Docker 25 - the image format did not change. I am talking about using a Docker installation in version 25 where Jib get's the image from the daemon <image>docker://any-image</image>

mpeddada1 commented 7 months ago

I am talking about using a Docker installation in version 25 where Jib get's the image from the daemon <image>docker://any-image</image>

I see, thanks for the clarification.

A follow-up q: do you run into the same issue when using the default base image? Specifically when you don't specify <from><image>docker://any-image</image></from>. Or when pulling in a base image from a container registry like this:

<configuration>
       <from><image>gcr.io/{REPO}/{NAME}:{TAG}</image></from>
</configuration>
derkoe commented 7 months ago

@mpeddada1

A follow-up q: do you run into the same issue when using the default base image?

I am using the default base image in my example above: eclipse-temurin:8-jre

Specifically when you don't specify docker://any-image. Or when pulling in a base image from a container registry like this.

The error only occurs when you specifiy the image from with the "docker://" prefix - this is exactly my bug description. It works if you do not specifiy the image.

Again: this error only occurs when the Docker image is loaded from the local Docker daemon with version >= 25. (using the docker:// prefix in the image from).

HajoRed commented 7 months ago

Today I ran into the same problem.

As a workaround I tried to create a tar with docker first by using docker save and then using tar:// as prefix in the image from, but this resulted in them same problem. So the tar prefix is affected as well, if the tar was created with daemon version >= 25

Noodlex commented 7 months ago

Since this day, bitbucket uses version 25 of docker in the pipelines. As a result, all my builds fail. I have no idea of an alternative solution to counter this big problem from my point of view.

Felix-Seip commented 7 months ago

Is there a timeline to release the fix in the near future? My Bitbucket pipelines currently don't work since Bitbucket cloud forces Docker v25. I could build the Docker image myself, but I would prefer to keep using jib...

datenbrille commented 6 months ago

Is there a plan to release it? It is currently breaking our builds too.

Romeh commented 6 months ago

hey any due date for the fix release as i see it is fixed in https://github.com/GoogleContainerTools/jib/pull/4172 ?

mpeddada1 commented 6 months ago

jib-core:0.26.0, jib-maven-plugin:3.4.1 and jib-gradle-plugin:3.4.1 have been released with this fix. Thanks for reporting @derkoe and thanks for making the fix @chanseokoh!