How to push an image to public ECR repository

siddharthjoshi September 14, 2021

I have tried using "atlassian/aws-ecr-push-image:1.4.2" to push an image to an existing repository in my AWS account. But unfortunately the pipe is only being able push to private repositories.

 

When i create a repository in public registry and try the same getting this following error

 

"The repository with name 'xxxxxxxx' does not exist in the registry with id 'xxxxxxxxx'"

3 answers

1 accepted

1 vote
Answer accepted
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2021

@siddharthjoshi@Kushan Harshana Gunasekera hi. We released new version of pipe:

  - pipe: atlassian/aws-ecr-push-image:1.5.0
    variables:
      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
      IMAGE_NAME: my-docker-image
      ECR_PUBLIC: "true"
      PUBLIC_REGISTRY_ALIAS: registry-alias

with support of pushing images to ECR Public Registry.

Please, provide us feedback.

Regards, Igor.

siddharthjoshi December 9, 2021

I would love to try this out @Igor Stoyanov , Will update one of my repositories and come back to you !!!

 

Thanks,


Siddharth Joshi K

Kushan Harshana Gunasekera December 10, 2021

Glad to hear that @Igor Stoyanov , I'll try it out. You have been a great help, Thank you @Igor Stoyanov .

0 votes
Kushan Harshana Gunasekera September 21, 2021

Here I've mentioned the reasons why this is happen in the Stack Overflow. Please have a look.

https://stackoverflow.com/q/69274998/6194097 

I think the "atlassian/aws-ecr-push-image:1.4.2" image doesn't support Amazon ECR Public repositories. I had the same issue, what I did was manually installed the AWS CLI version 2 in the pipeline and ran all the push commands.

That's it, but you must provide the region as us-east-1. Otherwise you'll get the same error again and again.

siddharthjoshi October 4, 2021

Yes, funnily i actually did the same :D

And even i faced this weird region (us-east-1) restrictions. But as you mentioned "atlassian/aws-ecr-push-image:1.4.2" does not seem to support public repo, as by default it's looking for a repo in the mentioned name in the private ECR and there were no parameters we could use to make it look in the public repo.

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 15, 2021

Hi @siddharthjoshi

Thank you for your question!

Have you provided all parameters required parameters for pipe?
Do you have permissions to push images to that repository?
It would be nice if you provide us with more details to help you: pipeline configuration, logs, etc.

 

Cheers,
Oleksandr Kyrdan

Kushan Harshana Gunasekera September 21, 2021

Hello @Oleksandr Kyrdan 

I'm having the same issue, the thing is Amazon ECR now supports public repositories. The aws ecr command is using for the private repositories and aws ecr-public command is using for the public repositories and public repositories are only work with us-east-1 region. I've addressed this issue in the Stack Overflow, please have a look for more details.

https://stackoverflow.com/q/69274998/6194097 

Like Igor Stoyanov likes this
siddharthjoshi October 4, 2021

@Oleksandr Kyrdan What @Kushan Harshana Gunasekera mentions is correct, to push to the public repo we need to use "aws ecr-public". I have permission to push to the repo, i have already pushed few images to my private repo and also i was able to push to public repo by writing the commands manually. The code below show how i managed to push the code to public ECR


```

pipelines:
default:
  - step:
name: "Build server image"
services:
  - docker
script:
- apt-get update
- docker build -t <image-name> .
- apt-get install -y python3-pip
- pip3 install -U awscli
- aws configure set aws_access_key_id <access-key-id>
- aws configure set aws_secret_access_key <secret-key>
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
- docker tag <image-name> public.ecr.aws/<repo-name>/<image-name>
- docker push public.ecr.aws/<repo-name>/<image-name>

```

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events