spotify / docker-maven-plugin

INACTIVE: A maven plugin for Docker
Apache License 2.0
2.67k stars 575 forks source link

Not able to authenticate after docker (for mac) update #348

Closed hotstepper13 closed 6 years ago

hotstepper13 commented 7 years ago

Description

We are using the maven plugin 1.0.0 with set up authentication in the settings.xml Registry is a private registry that require authentication to pull artifacts.

After updating the docker for mac software, the authentication doesn't work anymore.

With

Version 1.13.1 (15353)
Channel: Stable
94675c5a76

everything works as expected.

After updating to

Version 17.06.0-ce-mac19 (18663)
Channel: stable
c98c1c25e0

we got the errormessage

unknown: Authentication is required

Just for reference, using docker pull is working fine

docker pull xxxxxxxxxx/common/java-minimal:8.121-b13
8.121-b13: Pulling from common/java-minimal
3690ec4760f9: Pull complete 
a3ed95caeb02: Pull complete 
cf0184c44358: Downloading [=======================>                           ]  3.605MB/7.79MB
[...]

How to reproduce

Create a dummy project with working authentication while using docker for mac 1.x version. After verify that it works, update to the latest docker for mac version.

What do you expect

Build (and authentication) works same as before

What happened instead

Authentication didnt work anymore

Software:

Full backtrace

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (build-image) on project beaconservice: Exception caught: Get https://xxxxxxxxxxxxxxxxxxxxxxx/v2/common/java-minimal/manifests/8.121-b13: unknown: Authentication is required -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (build-image) on project beaconservice: Exception caught
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    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:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    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:498)
    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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught
    at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:151)
    at com.spotify.docker.BuildMojo.execute(BuildMojo.java:87)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: com.spotify.docker.client.exceptions.DockerException: Get https://xxxxxxxxxxxxxxxxxxxxxxx/v2/common/java-minimal/manifests/8.121-b13: unknown: Authentication is required
    at com.spotify.docker.client.AnsiProgressHandler.progress(AnsiProgressHandler.java:55)
    at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1389)
    at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1348)
    at com.spotify.docker.BuildMojo.buildImage(BuildMojo.java:580)
    at com.spotify.docker.BuildMojo.execute(BuildMojo.java:360)
    at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:149)
    ... 23 more
[ERROR] 
[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
mattnworb commented 7 years ago

What does your ~/docker/config.json or ~/.dockercfg file look like, minus any access tokens / sensitive info?

hotstepper13 commented 7 years ago

The Authentication information come from the settings.xml (added a server with encrypted password). We tried with working ~/.docker/config.json and also without it so I assume that this isn't related.

Tomorrow I want to trace down the exact version where it breaks. Maybe the changelog can give some hints what happens.

hotstepper13 commented 7 years ago

Here is the config.json. As said, we also tried it without it without any change

{
    "auths": {
        "xxxxxxxxxxxxxxxxx": {}
    },
    "credsStore": "osxkeychain"
}
hotstepper13 commented 7 years ago

Ok, thanks to the pointing of @mattnworb i was able to find a workaround. The issue seems to be related to the osxkechain. If this option is disabled and the config.json recreated everything works fine.

However, I do not understand why the credentials form the maven settings.xml are not used. During the run I can see the following output:

[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]

on a linux box I see the following output during run

[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier, ContainerRegistryAuthSupplier]

Are the credentials inside the settings.xml not supported on mac or do I need to configure the plugin in order to look there?

pdkovacs commented 7 years ago

Similar issue here with a plain setup (without docker-maven-plugin) https://github.com/docker/for-mac/issues/1994

davidxia commented 6 years ago

@hotstepper13 Does this fix the issue for you? https://github.com/spotify/docker-maven-plugin/pull/381

hotstepper13 commented 6 years ago

To be honest i live with the workaround as it also fits better in our approach.