Why my pipeline doesn't save my docker cache
Asked by Gregory ANNE:

I run my pipeline and at the end i have  
in the **Build teardown**  
a have  

    Assembling contents of new cache 'node'
    The docker cache will consist of all unique layers from the following images:
    XXXX                      latest                      0b36a0e36fe1        2 minutes ago       2.89GB
    XXXX   master                      0b36a0e36fe1        2 minutes ago       2.89GB
    <none>                            <none>                      2b8bbc83a9f5        2 minutes ago       2.88GB
    <none>                            <none>                      847beca8464e        2 minutes ago       2.88GB
    <none>                            <none>                      f743250d3034        3 minutes ago       2.88GB
    <none>                            <none>                      ab9f9a255307        3 minutes ago       2.87GB
    <none>                            <none>                      ad702401ef7b        3 minutes ago       2.86GB
    <none>                            <none>                      27b2c6836e41        4 minutes ago       2.8GB
    <none>                            <none>                      0eb31686926a        5 minutes ago       2.16GB
    <none>                            <none>                      69b7aab14d03        5 minutes ago       2.16GB
    <none>                            <none>                      c08aec3ba4f3        5 minutes ago       2.16GB
    <none>                            <none>                      eb026f344d64        6 minutes ago       2.16GB
    <none>                            <none>                      ea4d1f930f54        6 minutes ago       1.92GB
    cypress/browsers                  node14.16.0-chrome89-ff86   94078a0112a3        6 months ago        1.9GB

    Docker images saved to cache

    Searching for files matching artifact pattern test/**

    Finished scanning for test reports. Found 0 test report files.

    Merged test suites, total number tests is 0, with 0 failures and 0 errors.

After execution when I go in the caches button, but it seems the cache has not been really saved  
![Capture d?e?cran 2021-09-22 a? 18.17.47.png](https://community.atlassian.com/t5/image/serverpage/image-id/161589i204155B92F33A2E2/image-size/large?v=v2&px=999 "Capture d?e?cran 2021-09-22 a? 18.17.47.png")  
and if a restart a pipeline the Build setup indicate  

    Cache "docker": Downloading

    Cache "docker": Not found

    Cache "node": Downloading

    Cache "node": Not found

Does anyone have an idea of my mistake ?  
Here my pipeline file  

```
image: atlassian/default-image:2
 pipelines:
  default:
    - step:
        name: Build
        script: 
         - docker login XXX
         - docker build --tag test-ci .
         - docker tag test-ci XXXX
         - docker push XXX
        services:
         - docker
        caches:
         - docker
         - node
        artifacts:
         - test/**
```


Answers:
author: Caroline R
body: Hi, [@Gregory ANNE](/t5/user/viewprofilepage/user-id/3573754)!

Thank you for reaching out to Atlassian Community!

Checking your image, I can see that its size is huge, so this is the reason that cache is not saved. Only caches under 1 GB once compressed are saved. For the cache to compress to under 1 GB, the size of the original images in the Docker must be \< 2GB. In this case, I would suggest that you try to reduce the size of your image.

As mentioned in [this documentation](https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/), under "How does caching work?" section, you can check the size by adding this command to the script in your bitbucket-pipelines.yml:

```
docker image inspect $(docker image ls -aq) --format {{.Size}} | awk '{totalSizeInBytes += $0} END {print totalSizeInBytes}'
```

We already have a feature request to improve the message when we upload more than 1 GB as you can see here:

* <https://jira.atlassian.com/browse/BCLOUD-20205>

I would suggest that you add your vote there (by selecting the **Vote for this issue** link) as the number of votes helps the development team and product managers better understand the demand for new features.

You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the **Start watching this issue** link) if you'd like to get notified via email on updates.

Implementation of new features is done as per our policy [here](https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html) and any updates will be posted in the feature request.

I hope this helps, but do let me know if you have any questions.

Kind regards,  
Caroline

comments: author: Gregory ANNE
body: Thanks, we have update the docker image to reduce the size, and all work now.


author: Caroline R
body: Hi, Gregory!

That's great! Thanks for getting back to us, I'm glad to know everything is working now!

Kind regards,  
Caroline


Tags: bitbucket-pipelines

bitbucket-cloud

cache

cloud