The mystery is solved between Azure DevOps and AWS ECR Public

Kadriye Taylan
KoçSistem
Published in
3 min readMar 12, 2022

--

Hi everyone, In this article I will talk about the error I got while pushing images to the AWS ECR Public with the Azure Pipeline and a simple solution for this error.

First of all, I would like to explain the image repository services of AWS. There are two different types of AWS’s ECR service. These are AWS ECR(Private) and AWS ECR Public.

Amazon Elastic Container Registry (Amazon ECR) is an AWS managed container image registry service that is secure, scalable, and reliable. Amazon ECR supports private repositories with resource-based permissions using AWS IAM.

Amazon Elastic Container Registry Public is a managed AWS container image registry service that is secure, scalable, and reliable. Amazon ECR supports public image repositories with resource-based permissions using AWS IAM so that specific users can access your public repositories to push images.

If you define a private ecr, your ecr address will be as follows : https://<aws_account_id>.dkr.ecr.<region>.amazonaws.com

If you define a public ecr, your ecr address will be as follows : https://public.ecr.aws/<registry_alias>

Now we will create a service connection in azure devops to send an image to the public ecr address.

From the Project in Azure DevOps, go to Project Settings > Service Connection > Docker Registry > Others and write the connection information.

You can access the AWS Public ECR docker login information as in the image below:

The Azure Pipeline yaml file from which the docker image is pushed to the Registry is as follows.

When The pipeline runs with its configurations like this, an error as follows appears.

error parsing HTTP 404 response body: invalid character ‘p’ after top-level value: “404 page not found\n”##[error]error parsing HTTP 404 response body: invalid character ‘p’ after top-level value: “404 page not found\n”##[error]The process ‘/usr/bin/docker’ failed with exit code 1

Solving the error I looked at some places like stackoverflow, github and tried various solutions but none of them worked.

Then, when I examined the error detail, I saw that my registry url was as follows.

The push refers to repository [public.ecr.aws/myimagerepositoryname]

But the url should have been:

public.ecr.aws/<registry_alias>/myimagerepositoryname

As a solution, I updated my repository parameter in the pipeline yaml file as follows and I was able to successfully push my image to my public ecr repository.

- task: Docker@2
enabled: true
inputs:
containerRegistry: 'AWS Public ECR'
repository: '<registry_alias>/myimagerepositoryname'
command: 'buildAndPush'
Dockerfile: 'app/Dockerfile'
tags: '$(Build.BuildId)'

Even though I applied a workaround in this way, I was quite surprised that azure devops did not detect the id after the / sign in the url I gave in the service connection and threw such an error.

I will open an issue with microsoft on the subject. If it’s a bug they will fix it.

I hope it was an useful article. Have a nice day everybody :) Stay healthy!

--

--

Kadriye Taylan
KoçSistem

DevOps Engineer at Vanderlande - Eindhoven, NL