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 Respuesta
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

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas