Read Only Pipeline Docker Cache
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
How to use the Docker cache in a specific branch if it already exists but doesn't update/upload the cache from this branch.
In other words, use a READ-only Docker cache for a specific branch.
Solution
internally, Pipeline caches docker images by using docker image save during the teardown phase to save all the images then docker image load later at the time of build setup.
Users can run the following commands at the end of the step to remove all Docker images:
# Remove dangling images first
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
# Remove used images
docker rmi --force $(docker images --all --quiet)
This way the cache will be used if it exists but will not be uploaded to the Cache during the teardown phase as we have deleted all the images and no image exists.
Was this helpful?