10

I'm trying to run a Docker container on AWS Lambda. Specifically I'm following this official tutorial

I have the following Dockerfile

FROM public.ecr.aws/lambda/nodejs:12

COPY app app.js package.json /var/task/
RUN npm install

CMD [ "app.handler" ]

But, when I try to build this I get the following error:

docker build -t hello-world .

Sending build context to Docker daemon  4.608kB
Step 1/4 : FROM public.ecr.aws/lambda/nodejs:12
pull access denied for public.ecr.aws/lambda/nodejs, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.

When I login with docker login command I still get the same error.

Does anyone know how to resolve this?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Dirk Hoekstra
  • 942
  • 12
  • 16

2 Answers2

43

Works fine here. You shouldn't need credentials for Public ECR (you can use auth for specific cases) but if you just want to consume it, remove the existing credentials

docker logout public.ecr.aws

and then try the build again.

That said, if you still want to make use of the authentication, you need to re-auth as described in the doc

aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
0

Run the command: docker logout public.ecr.aws

Details: I got the similar error when trying to pull image for sam (Serverless Application Model) as follows:

Building codeuri: /Users/Machine1/Documents/tech/sam-demo/sklearn-sam-inference-demo runtime: None metadata: {'Dockerfile': 'Dockerfile', 'DockerContext':           
'/Users/Machine1/Documents/tech/sam-demo/sklearn-sam-inference-demo/app', 'DockerTag': 'python3.9-v1'} architecture: x86_64 functions: InferenceFunction             
Building image for InferenceFunction function                                                                                                                        
Setting DockerBuildArgs: {} for InferenceFunction function                                                                                                           
Step 1/6 : FROM public.ecr.aws/lambda/python:3.9

Build Failed
Error: InferenceFunction failed to build: pull access denied for public.ecr.aws/lambda/python, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.

As per the official documentation, to resolve this issue, you can either re-authenticate to Amazon ECR Public or you can log your Docker CLI out of the Amazon ECR Public registry and re-attempt your unauthenticated image pull.

docker logout public.ecr.aws
navule
  • 3,212
  • 2
  • 36
  • 54