My bitbucket build cannot pull docker image
Asked by Jason Novotny:

Previously I was using

```
image: openkbs/jdk11-mvn-py3
```

and this worked fine. Then I forked that docker image to fingage/jdk17-mvn-py3 and made sure it was public and changed the line:

```
image: fingage/jdk17-mvn-py3
```

Now I get an error

rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/fingage/jdk17-mvn-py3:latest": failed to resolve reference "docker.io/fingage/jdk17-mvn-py3:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

any ideas?

Thanks, Jason


Answers:
author: Patrik S
body: Hello [@Jason Novotny](/t5/user/viewprofilepage/user-id/273126)

Thank you for reaching out to Atlassian Community!

The error you reported is because that image either does not exist or is a private image. If you access the [**fingage**repository in Dockerhub](https://hub.docker.com/u/fingage) you can check that there's currently no public image listed with the name **jdk17-mvn-py3.**

If the image is private, you can use the following syntax in your Bitbucket pipelines yml file to provide the Docker hub credentials :

```
image:
  name: fingage/jdk17-mvn-py3
  username: $DOCKER_HUB_USERNAME
  password: $DOCKER_HUB_PASSWORD
```

However, if you want to set the image as public in your docker hub repository, you can follow Dockerhub's documentation to [Configure repositories.](https://docs.docker.com/docker-hub/repos/configure/)

Hope that helps! Let me know in case you have any questions.

Thank you, [@Jason Novotny](/t5/user/viewprofilepage/user-id/273126) .

Patrik S

comments: author: Jason Novotny
body: Thanks Patrik! That was very helpful


author: Patrik S
body: You're very welcome [@Jason Novotny](/t5/user/viewprofilepage/user-id/273126) ! Happy to have been of some help :)


author: ferpaxecosanxez
body: Does not run with "docker hub" images?

I have this YML:  

```
## Depth to clone project
clone:
  depth: full

## Use S4G image to manage Salesforce code
image:
  ## Use image from private Docker Hub
  name: s4gconsulting/devkops:latest
  username: $DOCKER_HUB_USERNAME
  password: $DOCKER_HUB_PASSWORD
  email: $DOCKER_HUB_EMAIL

pipelines:
  default:
    - step:
        name: Validate Docker Image
        script:
          - echo "Private image was pulled"
```

The result returns a right private image code SHA

![Screenshot 2023-04-04 at 18.54.07.png](https://community.atlassian.com/t5/image/serverpage/image-id/249793i10185FE6C6A28B84/image-size/large?v=v2&px=999 "Screenshot 2023-04-04 at 18.54.07.png")

But I have this error:

![Screenshot 2023-04-04 at 18.48.48.png](https://community.atlassian.com/t5/image/serverpage/image-id/249791i16B9412EEEB3DCFF/image-dimensions/366x242?v=v2 "Screenshot 2023-04-04 at 18.48.48.png")

Any ideas? Thanks =)


author: Patrik S
body: Hello [@ferpaxecosanxez](/t5/user/viewprofilepage/user-id/5187993) ,

The syntax you have used seems to be correct. Does the UI show any error message when you expand the **Build setup**section of the logs?

I would recommend trying to re-run the build and check if any error message is shown. If the authentication is wrong, it would be expected that an error would be shown saying that pipeline was not able to pull the image.

Also, make sure that the DOCKER_HUB_USERNAME, DOCKER_HUB_PASSWORD, and DOCKER_HUB_EMAIL are defined as environment variables in the repository or workspace level (see [Variables and Secrets](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/) ), and that they don't contain any typo/space that might be causing an error when authenticating with docker hub.

Thank you, [@ferpaxecosanxez](/t5/user/viewprofilepage/user-id/5187993) !

Patrik S


author: ferpaxecosanxez
body: Hello [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) , the UI does not show errors and the **image was pulled correctly** . I have opened [this question](https://community.atlassian.com/t5/Bitbucket-questions/Pipeline-pulls-docker-image-but-not-work/qaq-p/2322228) where I use **public images** but with the same fail result.

There you have all details and I hope that the community can help me.


Tags: bitbucket-cloud

cloud