I am using inline caching with my docker image. When running docker build locally, the cache is always used. In my pipelines, the behavior is inconsistent and usually results in the entire dockerfile building from scratch. I have not been able to figure out where the problem is.
This is the start of the dockerfile:
# syntax = docker/dockerfile:1.2
# Dockerfile for customer container for Lambdas.
# Author: Boris K., 2022.07.27
# ERB-2638
FROM --platform=linux/amd64 public.ecr.aws/lambda/python:3.12.2024.05.22.12@sha256:8b72b07c4eeba48a87799c6357ddf3d0abbd28dd3e0ead220427839cd160121f
RUN dnf install awscli \
gzip \
wget \
tar \
sudo \
unzip \
xorg-x11-fonts-* \
which \
cargo \
# below are needed the deps for LibreOffice
libXinerama \
java \
nss \
dbus-libs \
cups-libs \
-y && dnf clean all
Does anyone know why this first FROM command might pull from cache sometimes, but usually not? The layer should not be changing and the SHA is always the same. That is a static layer provided by AWS. So why would caching always work locally, but not in Bitbucket pipelines?
The command I am using for docker build is:
DOCKER_BUILDKIT=1 DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build . -t my_image:latest -f dockerfile --cache-from my_image:latest --build-arg BUILDKIT_INLINE_CACHE=1
Hi Boris,
I see that you created a support ticket for this issue as well. It is possible that you are affected by this bug https://jira.atlassian.com/browse/BCLOUD-23193 and one of my colleagues is investigating whether this is the case.
Kind regards,
Theodora
For anyone else who comes across this. Yes, there is a known issue with docker caching and since BuildKit has been disabled in Bitbucket, commands related to BuildKit commands, such as --cache--from and --cache-to, cannot be relied upon to work properly.
Bitbucket also has an internal ticket to remove --cache-from CLI option they reference in online documentation. That option should not be listed in example commands provided.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.