SpringBootApplication ECR-Gradle-Plugin dockerPushImage not working due to TAG
The problem that I am facing is that I am not able to push docker image to ECR. Docker Image is getting built successfully but it's not getting pushed as I am not aware how do I prepend the ECR url to my Docker Tag for Docker Push to work for ECR. I tried using 'tag' but then got the error :
Could not set unknown property 'tag' for extension 'springBootApplication' of type com.bmuschko.gradle.docker.DockerSpringBootApplication.
---- Gradle File Starts ---- plugins { id 'org.springframework.boot' version '2.2.4.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java' id "com.patdouble.awsecr" version "0.6.0" id 'com.bmuschko.docker-spring-boot-application' version '6.1.3' }
docker { springBootApplication { baseImage = 'openjdk:8-alpine' ports = [9091, 9091] images = ['my_ecr_repo/firstms:1.4'] }
registryCredentials {
url = 'https://123456789.dkr.ecr.us-east-1.amazonaws.com'
}
} ---- Gradle File Ends ---- ---- dockerPushImage command Starts --- [user@localhost firstms]$ ./gradlew dockerPushImage -PawsAccessKeyId=MY_ACCESS_ID -PawsSecretAccessKey=MY_SECRET
Task :dockerPushImage Pushing image 'my_ecr_repo/firstms:1.6'.
_> Task :dockerPushImage FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':dockerPushImage'. Could not push image: denied: requested access to the resource is denied_
---- dockerPushImage command Ends ---
This issue can be closed.
For resolution , this is what I did:
@bmuschko : Thanks for your help.
I found the fix, the issue was with my tag. Note this was causing the issue ":1.4"
Earlier (did not work): images = ['123456789.dkr.ecr.us-east-1.amazonaws.com/my_ecr_repo:firstms_:1.4_']
Later (worked): images = ['123456789.dkr.ecr.us-east-1.amazonaws.com/my_ecr_repo:firstms']
reference# https://github.com/bmuschko/gradle-docker-plugin/issues/921