Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

401 Unauthorized when using jib to create docker image

I am on windows and this is the plugin configuration:

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>3.2.1</version>
    <configuration>
        <container>
            <ports>
                <port>8080</port>
            </ports>
            <format>OCI</format>
        </container>
    </configuration>
</plugin>

This is the command I run:

.\mvnw clean install jib:dockerBuild -Dimage=fullstack:v1

This is the error I keep getting no matter what I do:

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.2.1:dockerBuild (default-cli) on project SpringBootFullStack: Build
 to Docker daemon failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/eclipse-temurin' are set up correc
tly. See https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized f
or help: Unauthorized for registry-1.docker.io/library/eclipse-temurin: 401 Unauthorized
[ERROR] {"details":"incorrect username or password"}
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

How should I go about it? I've read the documentation on jib github repo on authenticating but I don't really understand how to procede and feel overwhelmed

UPDATE

I ran docker login and I get:

Authenticating with existing credentials...
Login Succeeded

but the error persists (and I figured I didn't include some part of the logging maybe:

[INFO] Using credentials from Docker config (C:\Users\david\.docker\config.json) for openjdk:17
[INFO] Executing tasks:                               
[INFO] [============                  ] 40.0% complete
[INFO] > building image to Docker daemon              
[INFO]                                                
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.964 s
[INFO] Finished at: 2022-05-17T19:39:12+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.2.1:dockerBuild (default-cli) on project SpringBootFullStack: Build
 to Docker daemon failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/openjdk' are set up correctly. See
 Unauthorized for registry-1.docker.io/library/openjdk: 401 Unauthorized
[ERROR] {"details":"incorrect username or password"}
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

UPDATE 2

this is also the content of the file logs refer to in order to get username and password:

{
    "auths": {
        "https://index.docker.io/v1/": {}
    },
    "credsStore": "desktop"
}

UPDATE 3

After two days of trying I decided to look for something else that would do the same job: https://spring.io/guides/gs/spring-boot-docker/ And with this the job was done in ~10 minutes. Life really is crazy

like image 499
Davide _- Avatar asked Jun 04 '26 10:06

Davide _-


2 Answers

Just delete the credsStore property from the docker-config file. You will find the config.json at your user-home dir.

the path is: $USER/.docker/config.json and suppose the file contains the followings,

{
  "auths": {
    "https://index.docker.io/v1/": {}
  },
  "credsStore": "desktop"
}

and now delete the line : "credsStore": "desktop"

So, the file will now contain the following

{
  "auths": {
    "https://index.docker.io/v1/": {}
  }
}
like image 160
Khairul Bashar Lemon Avatar answered Jun 06 '26 01:06

Khairul Bashar Lemon


I had the issue on windows and solved the problem as follows:

Control Panel\All Control Panel Items\Credential Manager

From here I have removed in the Generic Credentials section all the entries related to docker

The from the powershell prompt:

docker login

and it worked!

like image 27
Gregory Risch Avatar answered Jun 06 '26 00:06

Gregory Risch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!