问题
I have a plugin to create a image, once created it need to be pushed to amazon ECR Please look into my plugin in the below`
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.24.0</version>
<configuration>
<dockerHost>https://accountID.dkr.ecr.us-east-1.amazonaws.com</dockerHost>
<authConfig>
<authToken>authorization Token</authToken>
<username>Access Key ID</username>
<password>Secret Key Id</password>
</authConfig>
<images>
<image>
<alias>service</alias>
<name>${project.artifactId}</name>
<build>
<from>openjdk:8-jdk-alpine</from>
<entryPoint>
<exec>
<arg>java</arg>
<arg>-jar</arg>
<arg>maven/app.jar</arg>
</exec>
</entryPoint>
<assembly>
<descriptorRef>artifact-with-dependencies</descriptorRef>
</assembly>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-build</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
`
I have tried with above plugin with authorization token as authtoken . when i am running maven build getting not authorized .
Help will be appreciated
Thanks, Damodar
回答1:
You can use the AWS ECR credential helper
Please read the documentation for further details, but here are the major steps to get it working:
- AWS credentials are set up (e.g. ~/.aws/credentials)
- install the ECR credential helper
- Adapt your ~/.docker/config.json (for us it has been the second mentioned option with specific aws account id)
{
"credHelpers": {
"accountID.dkr.ecr.us-east-1.amazonaws.com": "ecr-login"
},
... (already existing stuff in my setup)
}
- Use correct environment variables in the shell where the fabric8 maven-docker-plugin is executed:
AWS_SDK_LOAD_CONFIG=true
AWS_PROFILE=your_aws_profile
Maybe you will need to define AWS_REGION as environment variable as well.
Now when running the maven build, the ECR credential helper should take care of the authentication process, so the "authConfig"-part of the config in the question can be removed.
来源:https://stackoverflow.com/questions/49378313/how-to-push-docker-image-to-amazon-ecr-using-io-fabric8-maven-plugin-with-author