Pipeline won't refresh docker image to latest
Asked by Stephen Moon:

I recently updated a docker image used by an existing pipeline. But the pipeline continues to use a older (cached?) image.  

Old image sha: af561898ba  
New image sha: 4d1f87d6c1  

I've tried deleting the cache (not positive I did this correctly, we don't have any caching defined) and manually pulling the latest image in the pipeline yaml:  

- docker pull company/project:latest  

Which succeeds:
>
> Digest: sha256:4d1f87d6c1f8cec1e816558d176c2202feb3cb3c7a2f79321462e8b1b7f8275e`Status: Downloaded newer image for $DOCKERHUB_USERNAME/`project`:latest`  
[docker.io/$DOCKERHUB_USERNAME/project:latest](http://aa)  
But the later steps of the yaml still continue to use the older image:  
`From the 'Build Setup':`  
> Images used:  
> `build : `[docker.io/$DOCKERHUB_USERNAME/project@sha256:af561898bae54681f84551a1d4d4bc5aeeaa528e1d4097221dd671d553af6e5d](http://aa)

`The new image is available and 100% working, I was able to manually pull it and test it locally outside of the pipe. I also deleted all previous images on docker, so this must be a cached version via bitbucket some how.`  

`I think I need help a) clearing the docker image cache on bitbucket, or b) forcing pipe to use a specific docker image. I've already tried:`  

`image:`  
`name: `company/project:latest  
`username: $DOCKERHUB_USERNAME`  
`password: $DOCKERHUB_PASSWORD`  
`email: $DOCKER_IMAGE_REGISTRY_EMAIL`  

`for b) but it has no affect.`


Answers:
author: Theodora Boudale
body: Hi Stephen,

I would suggest creating a ticket with the support team about this issue. If we have an open support ticket, the engineer working on it will be able to access additional logs and investigate.

You can create a ticket via <https://support.atlassian.com/contact/#/>, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product. Please make sure to provide the build URL in the ticket description, so we can check the build logs and additional logs.

Kind regards,  
Theodora


author: Aron Gombas _Midori_
body: I remember we ran into this a few years ago. Our solution is that we update the Docker image only from the Pipeline with a custom build, which somehow flushes the previously cached Docker image.

It roughly looks like this (with parts removed):

```
pipelines:  default:
    ... removed  tags:    'docker-wdio-*':      - step:          image: atlassian/default-image:3          name: Update Pipeline Docker image          caches:            - docker          services:            - docker          script:            - cd test/synthetic            - docker build -t midoriglobal/carchc-wdio:latest .            - docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD            - docker push midoriglobal/carchc-wdio:latest  custom:    wdio-tests:      - step:          image: midoriglobal/carchc-wdio:latest          name: Browser tests          caches:            - node          script:
             .... removed
```

As you see, you have to run the build "docker-wdio-\*" to update the image, which will be used in all future "wdio-tests" builds.

I hope this helps.

comments: author: Stephen Moon
body: Appreciate the information, but unfortunately I wasn't able to get this to work either.


Tags: bitbucket-cloud

cloud