Failed to push to image (ECR)

I have been trying to push my built image into ECR. My ECR credentials are configured in the docker integration settings. From there on I have been facing issues in the pushing step and looked everywhere to make sense of the error, unfortunately, I cannot find anything that helps.

The error message:

Failed to push image

Logs:

name unknown: The repository with name ‘farisology/fyp-rahman’ does not exist in the registry with id ‘551650907187’

I would appreciate it if someone can point to me my mistake and help clarify to me what am missing here.

Here is my yaml file:

version: "1.0"
#Stages can help you organize your steps in stages
stages:
  - "clone"
  - "build"
  - "test"
  - "push"

steps:
  clone:
    title: "Cloning repository"
    type: "git-clone"
    repo: "farisology/fyp-rahman"
    # CF_BRANCH value is auto set when pipeline is triggered
    # Learn more at codefresh.io/docs/docs/codefresh-yaml/variables/
    revision: "${{CF_BRANCH}}"
    git: "github"
    stage: "clone"

  build:
    title: "Building Docker image"
    type: "build"
    image_name: "farisology/fyp-rahman"
    working_directory: "${{clone}}"
    tag: "${{CF_BRANCH_TAG_NORMALIZED}}"
    dockerfile: "Dockerfile"
    stage: "build"

  test:
    title: "Running test"
    type: "freestyle" # Run any command
    image: "ubuntu:latest" # The image in which command will be executed
    working_directory: "${{clone}}" # Running command where code cloned
    commands:
      - "ls"
    stage: "test"

  Push:
    type: "push"
    arguments:
      candidate: "${{build}}"
      registry: "farisology"
      stage: "push"

Hello.

Could you please provide the URL of the build that fails to push?

Have you also successfully pushed to this registry before using just plain docker commands (locally on your workstation)?

My bad I didn’t try pushing from local, I will try and report back.
For now here is the build URL: faild build in case there is any other issue.

What went wrong
So here is a description of the and how I managed to solve the issue.

In my push script, I am using the right repository name:

  Push:
type: "push"
arguments:
  candidate: "${{build}}"
  registry: "farisology"
  stage: "push"

The error message:

name unknown: The repository with name ‘farisology/fyp-rahman’ does not exist in the registry with id ‘551650907187’

So codefresh is trying to push to an ECR repository name ‘farisology/fyp-rahman’ meanwhile my actual repository name is ‘farisology’!!

I wonder why and how is that happening.

However, I have changed my image name in the Build step to be the ECR repository name. AND that worked fine.

Hello

I am glad it worked out. Yes there is much flexibility on naming. By default the build step creates a default image name and the push step re-uses it. I think this case works for most registries but AWS might be a bit different.

As you found out you can override the name in the build step. But you can also override the name in the push step as well :slight_smile:

The push step has an image_name that you can also use to customize the image name.

We are actually preparing several enhancements for build steps, which I think will simplify the situation a lot. https://codefresh.io/codefresh-news/new-docker-image-api-and-pipeline-build-step-enhancements/