fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.88k stars 643 forks source link

Better error message when image pulls fails because of failed authentication #337

Open rolfw opened 8 years ago

rolfw commented 8 years ago

I'm trying to pull images from a private repository. When I run $ mvn docker:start I get the following error:

$ mvn docker:start
....
....
[INFO] --- docker-maven-plugin:0.13.6:start (default-cli) @ j2objc-translation-interop-test ---
[INFO] DOCKER> ... Pulling repository somehostname.com:5000/v2/some-namespace/some-image
[ERROR] DOCKER> Error: image v2/some-namespace/some-image:latest not found 
[ERROR] DOCKER> Error occurred during container startup, shutting down...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.409 s
[INFO] Finished at: 2015-11-23T12:43:27+01:00
[INFO] Final Memory: 19M/310M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jolokia:docker-maven-plugin:0.13.6:start (default-cli) on project j2objc-translation-interop-test: I/O Error: Unable to pull 'somehostname.com:5000/v2/some-namespace/some-image:latest' -> [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

However, the URL that I provided in the <name/> property is correct and when I first run$ docker pull somehostname.com:5000/v2/some-namespace/some-image:latestand then try$ mvn docker:run` again it works without problems.

When I separate the repository and name and I include v2 it fails because the regex doesn't match:

<name>some-namespace</name> <repository>somehostname.com:5000/v2</repository>

What should be the correct configuration to make this work without manually pulling images first?

rolfw commented 8 years ago

Oops, never mind...

I found out it was my mistake: I assumed we didn't use authentication since I never use credentials. But it turned I logged in once with Docker when our devops engineer instructed me to do so when setting up the registry. After providing credentials it worked perfectly.

As a suggestion, it would be good if the plugin would respond with an authentication failure instead. Currently it suggests something is wrong with the URL or setup.

I won't close the issue then, in case you want to keep this as a feature/improvement request.

rhuss commented 8 years ago

Thanks for finding out ;-) I will have a look at the error message, but it could be, that Docker itself is not very specific about the error condition. Typically the plugin only passes through the error message coming from the Docker daemon.

In one of the next versions d-m-p will also look into ~/.docker/config.json in order to pick up the proper authentication when a docker login has been done previously.