Can't push my docker image to ecr

0

I am working with the AWS pipeline and in the build stage I need the docker image to be pushed to ECR .

The buildspec file for the same looks like this When the push command is executed it keeps retrying and retrying and then the command fails.All the previouse commands are run successfully except for the push command.

version:  0.2

phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
      - REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...
      - docker build -t $REPOSITORY_URI:$IMAGE_TAG .
      - docker tag $REPOSITORY_URI:$IMAGE_TAG $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - echo Writing image definitions file...
      - printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json

artifacts:
    files: imagedefinitions.json

1 個回答
0
  • Yeah I have this permissions attached to my codebuild role. I have added following additional policies just to make sure there is no permission issue

    AmazonEC2ContainerRegistryFullAccess AmazonS3FullAccess AmazonEC2ContainerRegistryPowerUser EC2InstanceProfileForImageBuilderECRContainerBuilds AWSAppRunnerServicePolicyForECRAccess

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南

相關內容