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

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容