spotify / docker-maven-plugin

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

Exception : Your Authorization Token has expired. Please run 'aws ecr get-login ' on Ubuntu #397

Closed govind22 closed 5 years ago

govind22 commented 6 years ago

Description

I'm using the docker maven plugin in order to build and push the docker image to the Aws ECR docker registry and it works fine on my windows machine but when I tried to run it on Teamcity Server (Ubuntu agent) it keeps throwing an exception while pushing it to the Registry.

I did not configure anything in my maven settings file. I usually login using below command $(aws ecr get-login --no-include-email --region my-region) then I run the maven commands (docker commands are embedded as a part of maven goals) and it works fine.

Now I'm doing the same thing on Ubuntu and it logs in successfully using docker -u user -p pwd command and I could push and pull images from ECR successfully by running manual docker commands but it does not works when I run mvn clean deploy (because of spotify plugin)

My Pom setup for spotify docker plugin

`

 <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>1.1.1</version>
        <configuration>
            <imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
            <dockerDirectory>docker</dockerDirectory>
           <!--  <serverId>docker-hub</serverId> -->
            <registryUrl>https://${docker.image.prefix}</registryUrl>
             <forceTags>true</forceTags>
            <resources>
                <resource>
                    <targetPath>/</targetPath>
                    <directory>${project.build.directory}</directory>
                    <include>${project.build.finalName}.jar</include>
                </resource>
            </resources>
        </configuration>
        <executions>
            <execution>
                <id>tag-image</id>
                <phase>package</phase>
                <goals>
                    <goal>build</goal>
                </goals>
            </execution>
            <execution>
                <id>push-image</id>
                <phase>deploy</phase>
                <goals>
                    <goal>push</goal>
                </goals>
                <configuration>
                    <imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
                </configuration>
            </execution>
        </executions>
    </plugin>`

What do you expect

As it works fine on windows then it should also work fine on Ubuntu

What happened instead

Docker setup : `

WARNING: No swap limit support Images: 14 Server Version: 18.06.0-ce Storage Driver: aufs Root Dir: /local/mnt/docker/aufs Dirperm1 Supported: false Logging Driver: json-file Cgroup Driver: cgroupfs Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Runtimes: runc Docker Root Dir: /local/mnt/docker Registry: https://index.docker.io/v1/ 127.0.0.0/8 Live Restore Enabled: false`

Full backtrace

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.1.1:push (push-image) on project triomotion_ble: Exception caught: denied: Your Authorization Token has expired. Please run 'aws ecr get-login --no-include-email' to fetch a new one. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:1.1.1:push (push-image) on project triomotion_ble: Exception caught at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) 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:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 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:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:151) at com.spotify.docker.PushMojo.execute(PushMojo.java:39) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: com.spotify.docker.client.exceptions.DockerException: denied: Your Authorization Token has expired. Please run 'aws ecr get-login --no-include-email' to fetch a new one. at com.spotify.docker.client.AnsiProgressHandler.progress(AnsiProgressHandler.java:55) at com.spotify.docker.Utils$DigestExtractingProgressHandler.progress(Utils.java:189) at com.spotify.docker.client.ProgressStream.tail(ProgressStream.java:74) at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1328) at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1308) at com.spotify.docker.Utils.pushImage(Utils.java:93) at com.spotify.docker.PushMojo.execute(PushMojo.java:55) at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:149) ... 22 more

I've already configured accesstoken, secretkey and session token as like windows. But Teamcity ubuntu agent keeps failing

Please help.

govind22 commented 6 years ago

I think its looking for the authtoken from somewhere else as per the logs

Using authentication suppliers: [ConfigFileRegistryAuthSupplier]

on windows I've set those as an env variables also in ubuntu. Thats why manual docker commands works fine because it refers to the env variables whereas docker plugin is looking it somewhere else.

stale[bot] commented 5 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.