<p>The error shows that you are using <code>AWS ECR</code> credentials to login to dockerhub which will not work. <code>Dockerhub</code> is a different registry(both public and private), however <code>ECR</code> is private registry only.</p>

<p>For pulling public images from <code>dockerhub</code> there is no need to login to dockerhub. You can simply use <code>docker pull</code> command and it will pull an image from dockerhub registry.</p>

<p>Example: <code>docker pull mongo</code></p>

<p>However, when you want to pull an image from <code>ECR</code>, you need to first login to the <code>AWS ECR</code> and then only you can pull an image from <code>ECR</code>.</p>

CC BY-SA 4.0
2019-11-17T18:02:34.110Z
2019-11-17T18:02:34.110Z
Samit
<p>I think your jenkins need to create an rapo with aws first for that what we normally do is, let's first do a manual pull from jenkins machine from ecr. Use ecr login command $ecr login (with ur region codes etc) is there, try that first ( to get full command open ECR in aws and click on ecr push command,  there u will get the full command). Then after successful login try again to pull the image this should pass. After getting this done try using jenkins pipeline.
All the best.</p>

CC BY-SA 4.0
2019-11-16T16:23:02.410Z
2019-11-16T16:23:02.410Z
Jithin Kumar S
<p>I am trying to create a Jenkins pipeline that will pull a public image from docker hub and build a Vue.js application inside that container. In my Jenkins server I already have other pipelines that use AWS ECR to push images too. It appears that my build that is trying to access a public image is trying to log into AWS ECR  as well. I'd be okay with putting that public image on ECR if that would solve my issue. </p>

<p>Here is the output of the failed Jenkins build</p>

<pre><code>[Pipeline] withDockerRegistry
$ docker login -u AWS -p ******** https://index.docker.io/v1/
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
[Pipeline] // withDockerRegistry
</code></pre>

<docker><jenkins><continuous-integration><jenkins-pipeline>
Jenkins and docker login issue
joshk132
# Jenkins and docker login issue

(Asked by: username_0 on 2019-11-16)

I am trying to create a Jenkins pipeline that will pull a public image from docker hub and build a Vue.js application inside that container. In my Jenkins server I already have other pipelines that use AWS ECR to push images too. It appears that my build that is trying to access a public image is trying to log into AWS ECR  as well. I'd be okay with putting that public image on ECR if that would solve my issue. 
Here is the output of the failed Jenkins build
[Pipeline] withDockerRegistry
$ docker login -u AWS -p ******** https://index.docker.io/v1/
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
[Pipeline] // withDockerRegistry

**Tags:** docker, jenkins, continuous-integration, jenkins-pipeline


---

## 2 answers

### Answer by username_1 on 2019-11-17. Score: 1

The error shows that you are using `AWS ECR` credentials to login to dockerhub which will not work. `Dockerhub` is a different registry(both public and private), however `ECR` is private registry only.

For pulling public images from `dockerhub` there is no need to login to dockerhub. You can simply use `docker pull` command and it will pull an image from dockerhub registry.

Example: `docker pull mongo`

However, when you want to pull an image from `ECR`, you need to first login to the `AWS ECR` and then only you can pull an image from `ECR`.


---

### Answer by username_2 on 2019-11-16. Score: 0

I think your jenkins need to create an rapo with aws first for that what we normally do is, let's first do a manual pull from jenkins machine from ecr. Use ecr login command $ecr login (with ur region codes etc) is there, try that first ( to get full command open ECR in aws and click on ecr push command, there u will get the full command). Then after successful login try again to pull the image this should pass. After getting this done try using jenkins pipeline.
All the best.


---

