Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pull access denied for Amazon ECR, repository does not exist or may require 'docker login'

  1. I have an image in an Amazon ECR Repository called workshop
  2. I have a Dockerfile to pull that image
  3. CodeBuild should build the new image from Dockerfile

Problem:

pull access denied for xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop, repository does not exist or may require 'docker login'

In my buildspec file, I've tried to login with docker, but nothing changes.

 phases:
  pre_build:
  commands:
   - echo Logging in to Amazon ECR...
   - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
   - aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 
     xxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com
   - CODEBUILD_RESOLVED_SOURCE_VERSION="${CODEBUILD_RESOLVED_SOURCE_VERSION:-$IMAGE_TAG}"
   - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)

Dockerfile looks like this:

FROM xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop:latest

CMD ["echo", "Hallo!"]

RUN code-server

What may cause the Problem?

like image 976
vasil001 Avatar asked Jan 21 '21 15:01

vasil001


People also ask

Which of the following commands must you run to pull existing docker images from ECR?

If you want to run a Docker image that is available in Amazon ECR, you can pull it to your local environment with the docker pull command.


Video Answer


1 Answers

Try to update your aws-cli and use latest version, because get-login is deprecated.

New command is like this:

aws ecr get-login-password \
    --region <region> \
| docker login \
    --username AWS \
    --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com

References:

  • get-login-password: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecr/get-login-password.html
  • get-login: https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login.html
like image 147
Daniel Hornik Avatar answered Nov 13 '22 04:11

Daniel Hornik