I cannot push a Docker image using the Jib Maven Plugin. I’m repeatedly getting a 401 Unauthorized error. I have not changed much, but the day before I got a 416 error. Here’s a quick summary of the problem:
Error message when using:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.example</groupId>
<artifactId>korfballteamapi</artifactId>
<version>0.0.1</version>
<name>KorfballTeamAPI</name>
<description>KorfballTeamAPI</description>
<organization>
<name>GlasgowKorfball</name>
<url>https://GlasgowKorfball.com</url>
</organization>
<properties>
<java.version>22</java.version>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<docker.username>rsmithuchot1</docker.username>
<start-class>org.example.korfballteamapi.KorfballTeamApiApplication</start-class>
</properties>
....Rest of POM
<build>
<plugins>
... rest of plugins
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.3</version>
<configuration>
<from>
<image>eclipse-temurin:22</image>
<platforms>
<platform>
<architecture>arm64</architecture>
<os>linux</os>
</platform>
<platform>
<architecture>amd64</architecture>
<os>linux</os>
</platform>
</platforms>
</from>
<to>
<image>docker.io/rsmithucot1/korfball-api</image>
<tags>
<tag>latest</tag>
</tags>
</to>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Error message:
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.4.3:build (default) on project korfballteamapi: Build image failed, perhaps you should make sure your credentials for ‘registry-1.docker.io/thisisanewimage’ are set up correctly. See https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized for help: Unauthorized for registry-1.docker.io/thisisanewimage: 401 Unauthorized.
[ERROR] HEAD https://registry-1.docker.io/v2/thisisanewimage/blobs/sha256:0806d5dbd9524f498cca7b9bea84c32bef6050eb04603092302d155b92fb411e
Error message when using:
<organization>
<name>GlasgowKorfball</name>
<url>https://GlasgowKorfball.com</url>
</organization>
<properties>
<java.version>22</java.version>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<docker.username>rsmithuchot1</docker.username>
<start-class>org.example.korfballteamapi.KorfballTeamApiApplication</start-class>
</properties>
enter code here
... rest of the POM
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.3</version>
<configuration>
<from>
<image>eclipse-temurin:22</image>
<platforms>
<platform>
<architecture>arm64</architecture>
<os>linux</os>
</platform>
<platform>
<architecture>amd64</architecture>
<os>linux</os>
</platform>
</platforms>
</from>
<to>
<image>docker.io/${docker.username}/${project.artifactId}:${project.version}</image>
<tags>
<tag>latest</tag>
</tags>
</to>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
Error message:
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.4.3:build (default) on project korfballteamapi: 416 Requested Range Not Satisfiable
[ERROR] PATCH https://registry-1.docker.io/v2/rsmithuchot1/korfballteamapi/blobs/uploads/ecfb7fe9-bf7b-4705-a25e-f2c4f9125e43?_state=GViHxJxiULvlBx3YP1PH-1qcnMEZ7KsgxbHLYqqhK2J7Ik5hbWUiOiJyc21pdGh1Y2hvdDEva29yZmJhbGx0ZWFtYXBpIiwiVVVJRCI6ImVjZmI3ZmU5LWJmN2ItNDcwNS1hMjVlLWYyYzRmOTEyNWU0MyIsIk9mZnNldCI6MCwiU3RhcnRlZEF0IjoiMjAyNC0wOS0xMlQxMjowMDo1MC4wMDY1MDE1NTJaIn0%3D
[ERROR] {“errors”:[{“code”:”RANGE_INVALID”,”message”:”invalid content range”}]}
Credentials configuration:
Here is the relevant part of my config.json
:
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "REDACTED_BASE64_ENCODED_CREDENTIALS"
},
"https://index.docker.io/v2/": {
"auth": "REDACTED_BASE64_ENCODED_CREDENTIALS"
}
},
"currentContext": "desktop-linux",
"plugins": {
"debug": {
"hooks": "exec"
},
"scout": {
"hooks": "pull,buildx build"
}
},
"features": {
"hooks": "true"
}
}
What I’ve tried:
-
Re-authenticated with Docker Hub: I used
docker login
to ensure my credentials are up-to-date. -
Verified credential encoding: The credentials appear to be base64-encoded correctly.
-
Checked Docker Hub URL: Confirmed that the registry URL is correct.
-
I downloaded and pushed an image: I downloaded a random image and pushed it to docker fine so that I can push from my command line.
Additional information:
-
Jib Maven Plugin Version: 3.4.3
-
Docker Config Location:
C:Usersricha.dockerconfig.json
-
Image Name:
thisisanewimage
-
Repository: “https://index.docker.io/v1/” or “https://index.docker.io/v2/”
Question:
What might be causing the 401 Unauthorized
error when using Jib to push the Docker image or the 416 Request Range Not Satisfiable
? Does it relate to when the image for the tumerin:22 is being pulled? Are there any specific issues with how credentials are managed or how Jib interacts with Docker Hub that I should be aware of? I do not understand why these credentials (the ones automatically generated by docker when logging in in the config file) are insufficient if I log in to the terminal to docker.