Jenkins and docker login issue 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
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.