# Failed to push to image (ECR)

**URL:** <https://community.codefresh.io/t/failed-to-push-to-image-ecr/329>\
**Category:** Pipeline Steps\
**Created:** [March 25, 2020, 5:12am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329 "2020-03-25T05:12:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![farisology](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/farisology/32/225_2.png) [@farisology](https://community.codefresh.io/u/farisology)\
**Post date:** [March 25, 2020, 5:12am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/1 "2020-03-25T05:12:15Z")

</div>

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"

```

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 25, 2020, 10:07am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/2 "2020-03-25T10:07:44Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![farisology](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/farisology/32/225_2.png) [@farisology](https://community.codefresh.io/u/farisology)\
**Post date:** [March 28, 2020, 11:58am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/3 "2020-03-28T11:58:58Z")

</div>

My bad I didn’t try pushing from local, I will try and report back.  
For now here is the build URL: [faild build](https://g.codefresh.io/build/5e7b3d210808564462f5910e) in case there is any other issue.

---

<div class="post-metadata">

**Author:** ![farisology](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/farisology/32/225_2.png) [@farisology](https://community.codefresh.io/u/farisology)\
**Post date:** [March 29, 2020, 4:29am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/4 "2020-03-29T04:29:10Z")

</div>

**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.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 30, 2020, 9:09am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/5 "2020-03-30T09:09:43Z")

</div>

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 🙂

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. [Our roadmap for the new Docker image API and pipeline build step enhancements | Codefresh](https://codefresh.io/codefresh-news/new-docker-image-api-and-pipeline-build-step-enhancements/)

---

<div class="post-metadata">

**Author:** ![devops1983](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/devops1983/32/462_2.png) [@devops1983](https://community.codefresh.io/u/devops1983)\
**Post date:** [February 10, 2022, 3:07pm UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/6 "2022-02-10T15:07:08Z")

</div>

@Kostis I did the same but this didnt work for me… my error is:

```auto
The push refers to repository [<accountid>.dkr.ecr.us-east-1.amazonaws.com/box/devops1983/python-flask-sample-app]        
EOF                                                                                                                        
[SYSTEM]                                                                                                                   
 Message Failed to push image                                                                                  
                     <awsaccountid>.dkr.ecr.us-east-1.amazonaws.com/box/devops1983/python-flask-sample-app:2.0.0             
 Caused by Container for operation: push. Failed with exit code: 1                                               
 Documentation Link https://codefresh.io/docs/docs/codefresh-yaml/steps/push/                                             
 Exit code 1                                                                                                     
 Name NonZeroExitCodeError      
pushtoecr:
    title: "pushing to Registry"
    type: "push"
    stage: "push"
    candidate: "${{build}}"
    tag: '2.0.0'
    registry: "amazon"

```

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [February 10, 2022, 3:54pm UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/7 "2022-02-10T15:54:24Z")

</div>

Hello.

As a first step you should try to push manually to your registry from your terminal using the standard docker push commands.

If that works, and Codefresh cannot push you need to open a ticket with us and include the URL of the build that has the issue so that they can investigate.

The error you are posting is generic and can mean different things (no such registry, wrong name in image, incorrect permissions etc).

---

<div class="post-metadata">

**Author:** ![devops1983](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/devops1983/32/462_2.png) [@devops1983](https://community.codefresh.io/u/devops1983)\
**Post date:** [February 11, 2022, 11:00am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/8 "2022-02-11T11:00:23Z")

</div>

ok sure i will try  
registry exists and that user has admin access  
image name also right…  
i will still go back and try pushing using docker push commands

---

<div class="post-metadata">

**Author:** ![devops1983](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/devops1983/32/462_2.png) [@devops1983](https://community.codefresh.io/u/devops1983)\
**Post date:** [February 24, 2022, 9:08am UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/9 "2022-02-24T09:08:43Z")

</div>

i could do this using docker push commands

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [February 25, 2022, 12:38pm UTC](https://community.codefresh.io/t/failed-to-push-to-image-ecr/329/10 "2022-02-25T12:38:09Z")

</div>

ok. Then please open a support issue with us and be sure to include the URL of the build that shows the issue.
