# Failed to pull private repository

**URL:** <https://forums.suse.com/t/failed-to-pull-private-repository/6030>\
**Category:** Rancher 1.x\
**Created:** [March 31, 2017, 10:18am UTC](https://forums.suse.com/t/failed-to-pull-private-repository/6030 "2017-03-31T10:18:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![irokhes](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@irokhes](https://forums.suse.com/u/irokhes)\
**Post date:** [March 31, 2017, 10:18am UTC](https://forums.suse.com/t/failed-to-pull-private-repository/6030/1 "2017-03-31T10:18:17Z")

</div>

I’m following this tutorial to create a Ci/CD pipeline  
[Docker-Based Build Pipelines – Continuous Deployment](http://rancher.com/continuous-deployment/)

I managed to push the image to the registry (I’ve tried dockerhub, amazon ECR and [quay.io](http://quay.io)) but when I try to deploy the image in a host I’m getting this error:  
(Expected state running but got error: Image [[quay.io/xxxx/projectname](http://quay.io/xxxx/projectname)] failed to pull: Pulling repository [quay.io/valeet/deathstar](http://quay.io/valeet/deathstar))

I use rancher-compose to fetch the images.

I’ve registered the credential for the registry in the Rancher admin tool.

Any Idea how to solve this?

---

<div class="post-metadata">

**Author:** ![satrapu](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/satrapu/32/2733_2.png) [@satrapu](https://forums.suse.com/u/satrapu)\
**Post date:** [August 26, 2017, 2:00pm UTC](https://forums.suse.com/t/failed-to-pull-private-repository/6030/2 "2017-08-26T14:00:26Z")

</div>

I believe you need to add the private Docker repository to your environment.  
Go to Rancher web UI -\> select specific environment -\> select menu Infrastructure -\> Registries -\> click button “Add Registry”.

---

<div class="post-metadata">

**Author:** ![Chris\_Garrett](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/chris_garrett/32/2302_2.png) [@Chris\_Garrett](https://forums.suse.com/u/Chris_Garrett)\
**Post date:** [August 28, 2017, 4:50pm UTC](https://forums.suse.com/t/failed-to-pull-private-repository/6030/3 "2017-08-28T16:50:07Z")

</div>

Just to build on what satrapu said:

There are instructions on how to add the ECR registry here: [http://rancher.com/using-amazon-container-registry-service/](http://rancher.com/using-amazon-container-registry-service/). Basically:

1. Add custom repository
2. Address is your ecr repo: `<your_project_id>.dkr.ecr.us-east-1.amazonaws.com/project-name`
3. Username is: `AWS`
4. Password is the output of `aws ecr get-login | cut -d ' ' -f 6`

The other thing I had to do is to setup recurring auth refresh. ObjectPartners has a container for this:

```
version: '2'
services:
  ecr-refresh:
    image: objectpartners/rancher-ecr-credentials
    environment:
      AWS_REGION: <YOUR_REGION>
      AWS_ACCESS_KEY_ID: <YOUR_KEY>
      AWS_SECRET_ACCESS_KEY: <YOUR_SECRET>
    stdin_open: true
    tty: true
    labels:
      io.rancher.container.agent.role: environment
      io.rancher.container.create_agent: 'true'
      io.rancher.container.pull_image: always
```
