dockerbuildx

docker buildx is ignoring the --no-cache flag


I'm trying to move my docker build environment to buildx.

At times I need buildx to ignore the existing cache so I pass the --no-cache option which worked well with docker build.

docker buildx build  --no-cache --pull --build-arg VERSION=4.0.0 --build-arg ONEPUB_TOKEN=xxxxx= -t onepub/xxx:4.0.0 -f vaadin.dockerfile .

The above command outputs:

[+] Building 4.6s (22/24)                                                                                                                                                                                               docker:default
 => [internal] load build definition from vaadin.dockerfile                                                                                                                                                                       0.0s
 => => transferring dockerfile: 2.17kB                                                                                                                                                                                            0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                 0.0s
 => => transferring context: 2B                                                                                                                                                                                                   0.0s
 => [internal] load metadata for docker.io/library/eclipse-temurin:17-jdk                                                                                                                                                         0.9s
 => CACHED [ 1/20] FROM docker.io/library/eclipse-temurin:17-jdk@sha256:4f29d78edde9ed752b3f0beef43988b87f37b52dfcbb3c718cd96c5fac7daf6c                                                                                          0.0s
 => [internal] load build context                                                                                                                                                                                                 0.0s
 => => transferring context: 2B                                                                                                                                                                                                   0.0s
 => [ 2/20] RUN mkdir -p /tmp/webp/unzipped                                                                                                                                                                                       3.3s
 => CACHED [ 3/20] RUN wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.3.2-linux-x86-64.tar.gz -O /tmp/webp/webp.tar.gz                                                                     0.0s
 => CACHED [ 4/20] RUN tar -xvf /tmp/webp/webp.tar.gz --directory /tmp/webp/unzipped                                                                                                                                              0.0s
 => CACHED [ 5/20] RUN ls -la /tmp/webp/unzipped/libwebp-1.3.2-linux-x86-64/bin/cwebp                                                                                                                                             0.0s
 => CACHED [ 6/20] RUN mv /tmp/webp/unzipped/libwebp-1.3.2-linux-x86-64/bin/cwebp /usr/bin/cwebp                                                                                                                                  0.0s
 => CACHED [ 7/20] RUN rm -rf /tmp/webp                                         


It would appear to me that it is using the cache. How do I resolve this issue?


Solution

  • This is a known quirk of output when the build fails and the RUN steps can be skipped by buildkit. If you fix the failing build, the steps would be executed without using the cache.