{"action":"opened","issue":{"url":"https://api.github.com/repos/spotify/docker-maven-plugin/issues/252","repository_url":"https://api.github.com/repos/spotify/docker-maven-plugin","labels_url":"https://api.github.com/repos/spotify/docker-maven-plugin/issues/252/labels{/name}","comments_url":"https://api.github.com/repos/spotify/docker-maven-plugin/issues/252/comments","events_url":"https://api.github.com/repos/spotify/docker-maven-plugin/issues/252/events","html_url":"https://github.com/spotify/docker-maven-plugin/issues/252","id":166774112,"number":252,"title":"Amazon ECR token in config.json not picked up","user":{"login":"ocker-docker-gummi-klokker","id":20555702,"avatar_url":"https://avatars.githubusercontent.com/u/20555702?v=3","gravatar_id":"","url":"https://api.github.com/users/ocker-docker-gummi-klokker","html_url":"https://github.com/ocker-docker-gummi-klokker","followers_url":"https://api.github.com/users/ocker-docker-gummi-klokker/followers","following_url":"https://api.github.com/users/ocker-docker-gummi-klokker/following{/other_user}","gists_url":"https://api.github.com/users/ocker-docker-gummi-klokker/gists{/gist_id}","starred_url":"https://api.github.com/users/ocker-docker-gummi-klokker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocker-docker-gummi-klokker/subscriptions","organizations_url":"https://api.github.com/users/ocker-docker-gummi-klokker/orgs","repos_url":"https://api.github.com/users/ocker-docker-gummi-klokker/repos","events_url":"https://api.github.com/users/ocker-docker-gummi-klokker/events{/privacy}","received_events_url":"https://api.github.com/users/ocker-docker-gummi-klokker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-21T09:21:31Z","updated_at":"2016-07-21T09:21:31Z","closed_at":null,"body":"## Description\r\nI'm trying to build and push an image to an AWS repository using the spotify docker-maven-plugin. \r\n\r\n[In this issue](https://github.com/spotify/docker-maven-plugin/issues/104) olkulyk asks:\r\n*Is it be possible to use an auth token from /.docker/config.json*\r\n\r\ndavidxia reply:\r\n*It's certainly possible*\r\n\r\nIt sounds like it should be pretty straight forward to do, but it turns out not to be (for me that is).\r\n\r\nTo start of with I have successfully created a token, build and tagged and image, and pushed it to my AWS repository. This was done manually from a docker terminal (Docker tools for Windows) following the steps provided by Amazon when the repository was created (see below). Ok - the prerequisites should be in order. No lets proceed to the actual task - building, tagging and pushing a docker image to Amazon ECR using the plugin.\r\n\r\n**_=================== BEGIN AMAZON GUIDE ==================_**\r\n\r\nSuccessfully created repository\r\nhttps://myaccount.dkr.ecr.us-east-1.amazonaws.com/my-dockers\r\n\r\n1) Retrieve the docker login command that you can use to authenticate your Docker client to your registry:\r\n\r\n\taws ecr get-login --region us-east-1\r\n\r\n2) Run the docker login command that was returned in the previous step.\r\n\r\n3) Build your Docker image using the following command. For information on building a Docker file from \r\n     scratch see the instructions here. You can skip this step if your image is already built:\r\n\r\n\tdocker build -t my-dockers .\r\n\r\n4) After the build completes, tag your image so you can push the image to this repository:\r\n\r\n\tdocker tag my-dockers:latest myaccount.dkr.ecr.us-east-1.amazonaws.com/my-dockers:latest \r\n\r\n5) Run the following command to push this image to your newly created AWS repository:\r\n\r\n\tdocker push myaccount.dkr.ecr.us-east-1.amazonaws.com/my-dockers:latest\r\n\t\r\n**_==================== END AMAZON GUIDE ===================_**\r\n\r\n\r\nTo start of with, I have generated a token manually (step 1 and 2 in the above guide). This will create a config.json in the .docker folder, containing the token (later I have to figure out how to do this automatically from maven). The challenge is now to get the docker-maven-plugin to use this token to push to ECR.\r\n\r\nIn the pom.xml the three execution blocks correspond to 3, 4 and 5 in the Amazon guide shown above.\r\n\r\n**_====================== START pom.xml ====================_**\r\n```\r\n<properties>\r\n\t<docker.image.name>my-dockers</docker.image.name>\r\n\t<docker.image.version>latest</docker.image.version>\r\n\t<docker.registry.host>https://myaccount.dkr.ecr.us-east-1.amazonaws.com</docker.registry.host>\r\n</properties>\r\n\r\n<plugin>\r\n\t<groupId>com.spotify</groupId>\r\n\t<artifactId>docker-maven-plugin</artifactId>\r\n\t<version>0.4.6</version>\r\n\t<configuration>\r\n\t\t<imageName>${docker.image.name}:${docker.image.version}</imageName>\r\n\t\t<!-- Define location of Dockerfile (only this file is located here) -->\r\n\t\t<dockerDirectory>${project.basedir}/docker/</dockerDirectory>\r\n\t\t<useConfigFile>true</useConfigFile>\r\n\t\t<dockerHost>${docker.registry.host}</dockerHost>\r\n\t\t<resources>\r\n\t\t\t<resource>\r\n\t\t\t\t<targetPath>files/</targetPath>\r\n\t\t\t\t<directory>${project.build.directory}</directory>\r\n\t\t\t\t<include>${project.build.finalName}.jar</include>\r\n\t\t\t</resource>\r\n\t\t\t<resource>\r\n\t\t\t\t<targetPath>files/libs/</targetPath>\r\n\t\t\t\t<directory>${project.build.directory}/libs</directory>\r\n\t\t\t\t<includes>\r\n\t\t\t\t\t<include>*.jar</include>\r\n\t\t\t\t</includes>\r\n\t\t\t</resource>\r\n\t\t</resources>\r\n\t</configuration>\r\n\t<executions>\r\n\t\t<!-- Build the image. Corresponds to 3 in the Amazon guide -->\r\n\t\t<execution>\r\n\t\t\t<phase>package</phase>\r\n\t\t\t<goals>\r\n\t\t\t\t<goal>build</goal>\r\n\t\t\t</goals>\r\n\t\t</execution>\r\n\t\t<!-- Tag the image. Corresponds to 4 in the Amazon guide -->\r\n\t\t<execution>\r\n\t\t\t<id>tag-image</id>\r\n\t\t\t<phase>package</phase>\r\n\t\t\t<goals>\r\n\t\t\t\t<goal>tag</goal>\r\n\t\t\t</goals>\r\n\t\t\t<configuration>\r\n\t\t\t\t<forceTags>true</forceTags>\r\n\t\t\t\t<image>${docker.image.name}:${docker.image.version}</image>\r\n\t\t\t\t<newName>${docker.registry.host}/${docker.image.name}:${docker.image.version}</newName>\r\n\t\t\t</configuration>\r\n\t\t</execution>\r\n\t\t<!-- Push the image. Corresponds to 5 in the Amazon guide -->\r\n\t\t<execution>\r\n\t\t\t<id>push-image</id>\r\n\t\t\t<phase>deploy</phase>\r\n\t\t\t<goals>\r\n\t\t\t\t<goal>push</goal>\r\n\t\t\t</goals>\r\n\t\t\t<configuration>\r\n\t\t\t\t<useConfigFile>true</useConfigFile>\r\n\t\t\t\t<forceTags>true</forceTags>\r\n\t\t\t\t<imageName>${docker.registry.host}/${docker.image.name}:${docker.image.version}</imageName>\r\n\t\t\t</configuration>\r\n\t\t</execution>\r\n\t</executions>\r\n</plugin>\r\n```\r\n**_======================= END pom.xml =====================_**\r\n\r\nUsing the ``` <useConfigFile>true</useConfigFile>``` I would expect the plugin to use the token found in:\r\n\r\nC:\\Users\\me\\\\.docker\\config.json \r\n\r\nI'm building the project with _mvn clean install -X_ to give me debug output.\r\nIt looks like everything is build correctly, except I get some debug output that may hint to the problem:\r\n\r\n[DEBUG] Auth Config null\r\n[DEBUG] C:\\Users\\me\\\\.docker\\ca.pem, C:\\Users\\me\\\\.docker\\key.pem or C:\\Users\\me\\\\.docker\\cert.pem does not exist, not using SSL\r\n[DEBUG] Not using any build profile\r\n\r\nI would expect the build image to be pushed to the Amazon ECR.\r\n\r\n## What happened instead\r\n\r\nWhat actually happens is a **_401 Unauthorized_** (se stacktrace below). Why is the plugin not picking up the token in config.json? Am I placing the config.json in the wrong location or am I missing something in the pom?\r\n\r\nNote that I generate the token right before building the project (and copy config.json to the .docker dir). Thus I don't think it's an invalid token.\r\n\r\n[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.6:build (default) on project MyProject: Exception caught: **_Request error: GET https://myaccount.dkr.ecr.us-east-1.amazonaws.com/version: 401: HTTP 401 Unauthorized_** -> [Help 1]\r\norg.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:0.4.6:build (default) on project MyProject: Exception caught\r\n\tat org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)\r\n\tat org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)\r\n\tat org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)\r\n\tat org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)\r\n\tat org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)\r\n\tat org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)\r\n\tat org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)\r\n\tat org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)\r\n\tat org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)\r\n\tat org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)\r\n\tat org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)\r\n\tat org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)\r\n\tat org.apache.maven.cli.MavenCli.main(MavenCli.java:197)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\r\n\tat java.lang.reflect.Method.invoke(Unknown Source)\r\n\tat org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)\r\n\tat org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)\r\n\tat org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)\r\n\tat org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)\r\nCaused by: org.apache.maven.plugin.MojoExecutionException: Exception caught\r\n\tat com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:126)\r\n\tat com.spotify.docker.BuildMojo.execute(BuildMojo.java:86)\r\n\tat org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)\r\n\tat org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)\r\n\t... 20 more\r\nCaused by: com.spotify.docker.client.exceptions.DockerRequestException: Request error: GET https://myaccount.dkr.ecr.us-east-1.amazonaws.com/version: 401\r\n\tat com.spotify.docker.client.DefaultDockerClient.propagate(DefaultDockerClient.java:1575)\r\n\tat com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:1514)\r\n\tat com.spotify.docker.client.DefaultDockerClient.version(DefaultDockerClient.java:394)\r\n\tat com.spotify.docker.client.DefaultDockerClient.authRegistryHeader(DefaultDockerClient.java:1622)\r\n\tat com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1123)\r\n\tat com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1082)\r\n\tat com.spotify.docker.BuildMojo.buildImage(BuildMojo.java:562)\r\n\tat com.spotify.docker.BuildMojo.execute(BuildMojo.java:347)\r\n\tat com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:124)\r\n\t... 23 more\r\nCaused by: com.spotify.docker.client.shaded.javax.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized\r\n\tat org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:984)\r\n\tat org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:799)\r\n\tat org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91)\r\n\tat org.glassfish.jersey.client.JerseyInvocation$5.completed(JerseyInvocation.java:760)\r\n\tat org.glassfish.jersey.client.ClientRuntime.processResponse(ClientRuntime.java:197)\r\n\tat org.glassfish.jersey.client.ClientRuntime.access$300(ClientRuntime.java:78)\r\n\tat org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:179)\r\n\tat org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)\r\n\tat org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)\r\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:315)\r\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:297)\r\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:267)\r\n\tat org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:340)\r\n\tat org.glassfish.jersey.client.ClientRuntime$3.run(ClientRuntime.java:209)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)\r\n\tat java.util.concurrent.FutureTask.run(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat java.lang.Thread.run(Unknown Source)\r\n[ERROR] \r\n[ERROR] \r\n[ERROR] For more information about the errors and possible solutions, please read the following articles:\r\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException\r\n\r\n\r\n## Software:\r\n\r\n- docker version: Docker tools (on Windows 7). Docker version 1.11.1, build 5604cbe\r\n- docker-maven-plugin version: 0.4.6\r\n- maven version: Apache Maven 3.3.3\r\n"}}
{"actor":{"display_login":"ocker-docker-gummi-klokker"}}