Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication is required failure with 0.11.5 #181

Closed
simon-temple opened this issue May 26, 2015 · 12 comments
Closed

Authentication is required failure with 0.11.5 #181

simon-temple opened this issue May 26, 2015 · 12 comments

Comments

@simon-temple
Copy link

When the Dockerfile processes the command:

    FROM docker.company.com/java8:latest

It fails as our private repo requires authentication.

I have the following in my .m2/settings.xml:

<!-- Our docker repo credentials -->
  <servers>
    <server>
      <id>docker-repo</id>
      <username>user</username>
      <password>password</password>
      <configuration>
        <email>simon.temple@company.com</email>
      </configuration>
    </server>
  </servers>

I also tried adding:

    <authConfig>
        <username>user</username>
        <password>password</password>
    </authConfig>

But I'm confused about this as the repo also requires email address when you login via docker:
docker login docker.company.com

BTW: This works and creates an entry in the .dockercfg file:

{
 "docker.company.com":
   { 
       "auth":"YW1hbHRvOlF1dnJwYVZ4VEc5Rw==",
       "email":"simon.temple@company.com"
   }
}

This is an extract from my mvn -X command:

[DEBUG] Connection can be kept alive indefinitely
[INFO] DOCKER> Step 0 : FROM docker.company.com/java8:latest
[DEBUG] http-outgoing-1 << "39[\r][\n]"
[DEBUG] http-outgoing-1 << "{"status":"Pulling repository docker.company.com/java8"}[\r][\n]"
[DEBUG] http-outgoing-1 << "[\r][\n]"
[INFO] DOCKER>   Pulling repository docker.company.com/java8
[DEBUG] http-outgoing-1 << "61[\r][\n]"
[DEBUG] http-outgoing-1 << "{"errorDetail":{"message":"Authentication is required."},"error":"Authentication is required."}[\r][\n]"
[DEBUG] http-outgoing-1 << "[\r][\n]"
[DEBUG] http-outgoing-1 << "0[\r][\n]"
[DEBUG] http-outgoing-1 << "[\r][\n]"
[ERROR] DOCKER> Error building image: Authentication is required.
[ERROR] DOCKER> Authentication is required.
[DEBUG] Connection [id: 1][route: {s}->https://192.168.59.103:2376][state: O=Boot2Docker] can be kept alive indefinitely
[DEBUG] Connection released: [id: 1][route: {s}->https://192.168.59.103:2376][state: O=Boot2Docker][total kept alive: 2; route allocated: 2 of 10; total allocated: 2 of 20]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.338 s
[INFO] Finished at: 2015-05-26T16:04:45+01:00
[INFO] Final Memory: 31M/769M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jolokia:docker-maven-plugin:0.11.5:build (default-cli) on project b2auth-docker-gce: Authentication is required. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jolokia:docker-maven-plugin:0.11.5:build (default-cli) on project b2auth-docker-gce: Authentication is required. 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.apache.maven.plugin.MojoExecutionException: Authentication is required. 
    at org.jolokia.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:136)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 25 more
Caused by: org.jolokia.docker.maven.access.DockerAccessException: Authentication is required. 
    at org.jolokia.docker.maven.access.chunked.BuildResponseHandler.process(BuildResponseHandler.java:27)
    at org.jolokia.docker.maven.access.chunked.BuildResponseHandler.process(BuildResponseHandler.java:7)
    at org.jolokia.docker.maven.access.chunked.TextToJsonBridgeCallback.process(TextToJsonBridgeCallback.java:23)
    at org.jolokia.docker.maven.access.chunked.TextToJsonBridgeCallback.process(TextToJsonBridgeCallback.java:9)
    at org.jolokia.docker.maven.access.chunked.ChunkedResponseReader.process(ChunkedResponseReader.java:25)
    at org.jolokia.docker.maven.access.DockerAccessWithHttpClient.processChunkedResponse(DockerAccessWithHttpClient.java:461)
    at org.jolokia.docker.maven.access.DockerAccessWithHttpClient.buildImage(DockerAccessWithHttpClient.java:142)
    at org.jolokia.docker.maven.BuildMojo.buildImage(BuildMojo.java:82)
    at org.jolokia.docker.maven.BuildMojo.executeInternal(BuildMojo.java:64)
    at org.jolokia.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:134)
    ... 27 more
[DEBUG] Connection manager is shutting down

TIA

Simon

@simon-temple
Copy link
Author

Great... all the xml notation I added has been stripped. Sorry!

@rhuss
Copy link
Collaborator

rhuss commented May 26, 2015

(fixed the XML formatting, you need to embedd it in backticks. See the source, how)

For the authentication to work, the server <id> must match your registry name. So, in you case it should read like

<server>
      <id>docker.company.com</id>
      <username>user</username>
      <password>password</password>
</server>

E-Mail ist not necessary. Please let me know if this works for you.

@simon-temple
Copy link
Author

I'm sorry this does not work form.

[INFO] DOCKER> Step 0 : FROM docker.company.com/java8:latest
[INFO] DOCKER> Pulling repository docker.company.com/java8
[ERROR] DOCKER> Error building image: Authentication is required.
[ERROR] DOCKER> Authentication is required.

This is from my .m2/settings.xml:

docker.company.com username password simon.temple@company.com

On 26 May 2015 at 20:35, Roland Huß notifications@github.com wrote:

(fixed the XML formatting, you need to embedd it in backticks. See the
source, how)

For the authentication to work, the server must match your registry
name. So, in you case it should read like

docker.company.com user password

E-Mail ist not necessary. Please let me know if this works for you.


Reply to this email directly or view it on GitHub
https://github.com/rhuss/docker-maven-plugin/issues/181#issuecomment-105643344
.

@simon-temple
Copy link
Author

I have done some more testing and confirm this is only an issue if running
my own Dockerfile (i.e. not one generated via the POM instructions.

The workaround for me is to stop using a custom Dockerfile in
src/main/docker and let your code build one for me.

On 26 May 2015 at 20:35, Roland Huß notifications@github.com wrote:

(fixed the XML formatting, you need to embedd it in backticks. See the
source, how)

For the authentication to work, the server must match your registry
name. So, in you case it should read like

docker.company.com user password

E-Mail ist not necessary. Please let me know if this works for you.


Reply to this email directly or view it on GitHub
https://github.com/rhuss/docker-maven-plugin/issues/181#issuecomment-105643344
.

@rhuss
Copy link
Collaborator

rhuss commented May 27, 2015

Ah, good to know. Thanks. Might indeed be a bug, I will hunt for it :)

@jdavisonc
Copy link

It seems to be a bug when building a image with an external Dockerfile which has a base image from a private repository. In this case, the plugin doesn't send the correspondent credential, in consecuence it fails.

    private void autoPullBaseImage(DockerAccess dockerAccess, ImageConfiguration imageConfig)
            throws DockerAccessException, MojoExecutionException {
        BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
        String fromImage = buildConfig.getFrom();
        if (fromImage == null) {
            AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
            if (assemblyConfig == null || assemblyConfig.getDockerFileDir() == null) {
                fromImage = DockerAssemblyManager.DEFAULT_DATA_BASE_IMAGE;
            }
        }
        if (fromImage != null) {
            checkImageWithAutoPull(dockerAccess, fromImage, new ImageName(fromImage).getRegistry(),true);
        }
    }

Method autoPullBaseImage it only try to get the base image from "<from/>" tag, it doesn't read the "FROM" section of the Dockerfile. I don't if this was done on porpouse or is just a bug.

@jdavisonc
Copy link

@rhuss
Copy link
Collaborator

rhuss commented Jul 17, 2015

"serveradress" is only required when calling the /auth API to verify authentication. But we are authenticating directly by setting the Authorization: HTTP Header (where only user,password and email is required, base64 encoded).

It seem indeed an issue when using the external Dockerfile and I'm also not sure that it does any autopull when doing the the build (because I don't parse yet the dockerfile but use it 'as it'). I will have a look at it (but not before monday), but I'm open for any PR, so feel free to submit one ;-)

thanks ...

@jdavisonc
Copy link

Based on these links the "serveradress" is required:

Maybe different versions of Docker behaves in a different way?

My configuration

Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64

jdavisonc pushed a commit to jdavisonc/docker-maven-plugin that referenced this issue Jul 17, 2015
@dverbeek84
Copy link

@jdavisonc private repo without serveradress just works fine with docker 1.6.2.
I still have to problem of pulling the image with a external Dockerfile.
For the workaround you can add <FROM>image</FROM> to your build step.

@jdavisonc
Copy link

Yes, If I add the tag on plugin configuration it works.

@rhuss
Copy link
Collaborator

rhuss commented Apr 14, 2018

Authentication support has been extended quite a bit since that time. I'm going to close this issue, but feel to reopen it or open a new issue if authentication still does not work as expected.

@rhuss rhuss closed this as completed Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants