Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Buildkit cache-from not working

Thor Zhong
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 7, 2022

I'm checking the newly available feature in the pipeline for the docker buildkit. Trying to utilize the build cache feature to improve the build speed. But after some tests, I noticed the cache layer can't be reused consistently. 

The build command I used is

docker build orch-tool --tag image-name --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from image-name-at-registry
docker tag image-name image-name-at-registry
docker push image-name-at-registry

I tested the above commands locally without issue, and the caching works perfectly. But when tested in the pipeline, it doesn't work.

The dockerfile contains `apt update` in early layers, not sure if this is the problem.

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 12, 2022

Hi @Thor Zhong,

 

(1) Does caching not work at all in Pipelines?
Or does it not work in some builds?
Or does it work only for some layers?

I am trying to understand the scope of the issue you are reporting.

 

(2) Have you added the following command in the script of your bitbucket-pipelines.yml file (before the docker build command)?

- export DOCKER_BUILDKIT=1

This is necessary in order to be able to use Docker BuildKit in Bitbucket Pipelines.

 

(3) Are you using this in Pipelines builds that run in our own infrastructure, or have you set up runners that run in your own infrastructure?

 

Kind regards,
Theodora

Thor Zhong
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 14, 2022

1. The cache works in some builds. But failed more often I can feel

2. Yes, I did this export

3. I'm using runners from bitbucket infrastructure. 

For example, I ran three builds one after another. They all have the same sha256 (not sure if you can see it clearly) at the same layer, but build 12 used the cache layer while build 15 did apt installation again. I think build 12 ran 1 day after build 11 finished, build 15 ran 4 days after

#11No11.png

#12

No12.png

#15

No15.png

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 17, 2022

Hi @Thor Zhong,

Thank you for the info.

My guess is that there may be a change between the different Pipelines builds either in the base image you are using in your Dockerfile or in one of the tools you are installing with the apt install command, which makes the dependencies get downloaded again.

Are you using a public Docker image as a base image in the Dockerfile? If so, would you mind sharing which image it is and also the full list of tools you are installing with apt install, so I can try to reproduce and investigate?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events