spotify / dockerfile-maven

MATURE: A set of Maven tools for dealing with Dockerfiles
Apache License 2.0
2.76k stars 494 forks source link

BUG REPORT: Plugin does not take into account the env var DOCKER_CONFIG for credentials #191

Closed quentingodeau closed 6 years ago

quentingodeau commented 6 years ago

Description

When using Jenkins jobs, the environment variable DOCKER_CONFIG is redefine to a local path instead of the usual ~/.docker/

taken from the official docker website

How to reproduce

  1. Assure that you do not have any ~/.docker/config.json or ~/.dockercfg file
  2. Define export DOCKER_CONFIG to /tmp/
  3. Run maven job

What do you expect

The plugin take into account the environment variable and read the file from it.

What happened instead

A java exception occur:

Caused by: com.spotify.docker.client.exceptions.DockerException: Get http://mydockerhub/v2/openjdk/manifests/8-jre-alpine: no basic auth credentials

(cf: full backtrace)

Software:

Server: Engine: Version: 17.12.1-ce API version: 1.35 (minimum version 1.12) Go version: go1.9.4 Git commit: 7390fc6 Built: Tue Feb 27 22:17:54 2018 OS/Arch: linux/amd64 Experimental: true

- Spotify's dockerfile-maven version: 1.4.3

## Full backtrace

org.apache.maven.plugin.MojoExecutionException: Could not build image at com.spotify.plugin.dockerfile.BuildMojo.buildImage (BuildMojo.java:185) at com.spotify.plugin.dockerfile.BuildMojo.execute (BuildMojo.java:105) at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute (AbstractDockerMojo.java:252) at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute (AbstractDockerMojo.java:241) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) 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:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) 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: com.spotify.docker.client.exceptions.DockerException: Get http://mydockerhub/v2/openjdk/manifests/8-jre-alpine: no basic auth credentials at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleError (LoggingProgressHandler.java:105) at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress (LoggingProgressHandler.java:63) at com.spotify.docker.client.DefaultDockerClient.build (DefaultDockerClient.java:1443) at com.spotify.docker.client.DefaultDockerClient.build (DefaultDockerClient.java:1402) at com.spotify.plugin.dockerfile.BuildMojo.buildImage (BuildMojo.java:178) at com.spotify.plugin.dockerfile.BuildMojo.execute (BuildMojo.java:105) at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute (AbstractDockerMojo.java:252) at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute (AbstractDockerMojo.java:241) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) 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:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) 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)

yueli9 commented 6 years ago

+1, please consider supporting this!

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

albanf commented 5 years ago

The root cause of this issue is in the docker-client. I have submitted a PR: https://github.com/spotify/docker-client/pull/1145 If it's accepted, this maven plugin will need to be updated to use the latest version of the client.