I am trying to build a sample java project and trying to build an docker image and pushing that image to AWS ECR, but facing an issue while logging into the AWS ECR.
Error: COMMAND_EXECUTION_ERROR: Error while executing command: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/z8i5y3u6. Reason: exit status 1
I used below buildspec.yml file for build. Not sure where I am doing mistake, please help me to fix this issue.
version: 0.2
phases:
install:
runtime-versions:
java: corretto8
docker: 18
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/z8i5wy3u
build:
commands:
- echo Build started on date
- mvn package
post_build:
commands:
- echo Building the Docker image...
- docker build -t atlas2-au .
- docker tag atlas2-au:latest public.ecr.aws/z8i5y3u6/atlas:latest
- docker push public.ecr.aws/z8i5y3u6/atlas2-au:latest