Same Dockerfile and build context, different layer digests

86 views Asked by At

I'm building the following Dockerfile twice using buildx. For some reason I fail to understand the layers produced from the RUN command have different digests. The two executions of the build happen within seconds on the same host (tried on both Mac Intel, Docker Engine 24.06 and Ubuntu 20.04, Docker version 24.0.7).

This is the Dockerfile:

FROM python:3.10-slim-bullseye 

RUN sh -c "echo hello" 

These are the commands I'm using to run the build twice:

docker buildx build --build-arg BUILDKIT_STEP_LOG=1 --progress plain --no-cache --tag ca-test:1 . 
docker buildx build --build-arg BUILDKIT_STEP_LOG=1 --progress plain --no-cache --tag ca-test:2 .  

The resulting layer digests (RootFS.Layers) for the first build are:

  "sha256:74c0af6e02274b54b88f851843ae69880a234694dede8ff9fb93bfa076af45ed",
  ...
  "sha256:9647f452a52939a4807a7534ecbac34470618d7822881739b99c076862f69fdf",
  "sha256:a12f7c086f54288199c551849f2ece71758541ca02bda42793a6e8efe754b91f"

While for the second build, they are (note the difference in the last layer):

  "sha256:74c0af6e02274b54b88f851843ae69880a234694dede8ff9fb93bfa076af45ed",
  ...
  "sha256:9647f452a52939a4807a7534ecbac34470618d7822881739b99c076862f69fdf",
  "sha256:cf80db41eb34c3282f4456b0b71bab7c0521078e60cccbc01de407197dd54b6d"

Any help would be greatly appreciated.

0

There are 0 answers