3

I was trying to build the docker image for a project I'm working onto. It's based on jhipster, after configuring the project it tells me to run the following maven command:

./mvnw -ntp -Pprod verify jib:dockerBuild

Unfortunately it doesn't seem to work, it returns me this errors:

[WARNING] The credential helper (docker-credential-pass) has nothing for server URL: registry.hub.docker.com
...
[WARNING] The credential helper (docker-credential-pass) has nothing for server URL: index.docker.io
[WARNING] 

And finally fails with:

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.4.0:dockerBuild (default-cli) on project booking: (null exception message): NullPointerException -> [Help 1]

Recently I worked on a google cloud project, and I edited the ~/.docker/config.json configuration file. I had to remove google's configuration entries to sort out another problem. Could that be the origin of the problem I'm facing now?

I've tried to do docker logout and docker login without success.

funder7
  • 1,622
  • 17
  • 30

2 Answers2

6

Some considerations

I don't know if editing manually the configuration caused the error, in fact I'm pretty sure to have deleted only google-related entries, but nothing referring to docker.* or similar.

To solve this issue, avoid to edit manually the docker configuration file. In fact I think that it should be avoided whenever possible, to avoid configuration problems of any sort.

Instead, just follow what the error message is trying to tell you: docker is not able to access those urls. Excluding network problems (which you can troubleshoot with ping registry-1.docker.io for example), it should be an authentication problem.

How to fix

I've found out that running those commands fixed it:

docker login registry.hub.docker.com

docker login registry-1.docker.io

I don't know if registry-1.docker.io is just a mirror of the other first server, which the plugin tries to access after the first unsuccessful connection. You can try to loging to registry.hub.docker.com and re-launch the command to see if it sufficient. In case it's not, login to the second one and then it will work.

funder7
  • 1,622
  • 17
  • 30
0

I ran jib via Gradle:

./gradlew jibDockerBuild

and got a similar error

FAILURE: Build failed with an exception.
 
* What went wrong:
Execution failed for task ':jibDockerBuild'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: Build to Docker daemon failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/openjdk' 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

What ended up solving this error for me, bizarrely enough, was to log out of Docker Desktop.

I later also tried funder7's solution while logged in to Docker Desktop, and that also worked.

Toldry
  • 485
  • 1
  • 4
  • 13