You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an ENV variable is set to a value from ARG and ENV is not subsequently used in a RUN or such, buildah does not invalidate the cache. Instead an older cache entry, with the wrong ENV value is used. This does not happen if the ARG or ENV is used in a subsequent RUN step.
Repro
Dockerfile content
FROM debian:stable
ARG counter
ENV something=$counter
Execute the following a few times:
counter=$counter|| 1; counter=$(($counter+1)); buildah build --layers --build-arg counter=$counter --tag testme .&&echo expected counter value: $counter, is $(podman run --rm -it testme sh -c 'echo $something')
This will build an image with an increasing value for counter and print the value of $something. The use of podman here is just for brevity's sake.
STEP 1/3: FROM debian:stable
STEP 2/3: ARG counter
--> Using cache c9ceef6f746eb9fe78b011cf4314a0554e41e4036541fd4f46baa7dd0edede94
--> c9ceef6f746e
STEP 3/3: ENV something=$counter
--> Using cache e06fc858d20aedee6acfa73a67323d22f7def3544624f183fa9b72250b977a8c
COMMIT testme
--> e06fc858d20a
Successfully tagged localhost/testme:latest
e06fc858d20aedee6acfa73a67323d22f7def3544624f183fa9b72250b977a8c
expected counter value: 2, is 1
Note that the resulting image ID is the same.
Describe the results you expected:
The second run should not have reused the cached image. I.e. instead of expected counter value: 2, is 1, the output should have been expected counter value: 2, is 2.
If I add
RUN echo $counter
or
RUN echo $something
to the tail of the Dockerfile, the issue does not occur.
I'm seeing this, too, in debian bookworm, podman v4.3.1
(and it's mangling my conversion at archive.org from docker to podman for self-hosted gitlab runner)
FROM busybox
ARG NUM
ENV NUM=${NUM}
ENTRYPOINT echo is $NUM
N=1; podman build -t nix$N --build-arg NUM=$N.
N=2; podman build -t nix$N --build-arg NUM=$N.
podman run nix1
is 1
podman run nix2
is 1
Hi,
Description
When an ENV variable is set to a value from ARG and ENV is not subsequently used in a RUN or such, buildah does not invalidate the cache. Instead an older cache entry, with the wrong ENV value is used. This does not happen if the ARG or ENV is used in a subsequent RUN step.
Repro
Dockerfile content
Execute the following a few times:
This will build an image with an increasing value for
counter
and print the value of $something. The use of podman here is just for brevity's sake.Describe the results you received:
The first run is as expected:
but the second run reuses the prior image:
Note that the resulting image ID is the same.
Describe the results you expected:
The second run should not have reused the cached image. I.e. instead of
expected counter value: 2, is 1
, the output should have beenexpected counter value: 2, is 2
.If I add
RUN echo $counter
or
RUN echo $something
to the tail of the Dockerfile, the issue does not occur.
Output of
rpm -q buildah
orapt list buildah
:Reproduces with both of the above.
Output of
buildah version
:Output of
uname -a
:Greetings,
Andres
The text was updated successfully, but these errors were encountered: