-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUN bind mount not cached when using extra build context #5560
Comments
I'm unfamiliar with this code base, but if this is expected to work but no one has the time to debug it I'd be grateful if someone could point me to a good starting location in the code. If I find the time maybe I can at least shorten the overall time it takes for this ticket to get resolved. |
If it works with a docker build then it should work with buildah. Most likely there is no one able to work on this now. |
Hm I thought I had tested this with docker, but it looks like you're right @rhatdan. This behaves the same with docker: $ docker build -t test-mounting:latest --build-context mycon=. -f test_mounting.Containerfile .
[+] Building 0.9s (11/11) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from test_mounting.Containerfile 0.0s
=> => transferring dockerfile: 395B 0.0s
=> [internal] load metadata for docker.io/library/centos:7 0.0s
=> [context mycon] load .dockerignore 0.0s
=> => transferring mycon: 2B 0.0s
=> [compilers 1/5] FROM docker.io/library/centos:7 0.0s
=> [context mycon] load from client 0.0s
=> => transferring mycon: 437B 0.0s
=> CACHED [compilers 2/5] WORKDIR /work 0.0s
=> CACHED [compilers 3/5] RUN echo "Current directory: ${PWD}" && ls -lR . 0.0s
=> [compilers 4/5] RUN --mount=type=bind,source=test.txt,target=test.txt,from=mycon stat -c '%a %u %U %g %G %W %X %Y %Z' test.txt 0.3s
=> [compilers 5/5] RUN ls -la /work && echo "DONE" >> a_file.txt 0.5s
=> exporting to image 0.1s
=> => exporting layers 0.1s
=> => writing image sha256:6824f59b7c8a214595432afecfcde008e1ebf0bd715eb58814bf3a385f238bfd 0.0s
=> => naming to docker.io/library/test-mounting:latest Note no CACHE line for the => CACHED [compilers 2/5] WORKDIR /work 0.0s
=> CACHED [compilers 3/5] RUN echo "Current directory: ${PWD}" && ls -lR . 0.0s
=> CACHED [compilers 4/5] RUN --mount=type=bind,source=test.txt,target=test.txt stat -c '%a %u %U %g %G %W %X %Y %Z' test.txt 0.0s
=> CACHED [compilers 5/5] RUN ls -la /work && echo "DONE" >> a_file.txt So in that case...I guess I file this with docker somewhere? EDIT: I found an old terminal session output where in my real world use case the docker output did cache the EDIT 2: Looks like docker caches it if the extra context isn't the current directory (or maybe the same as the base context). EDIT 3: Podman doesn't seem to cache in any of these situations. |
@flouthoc PTAL |
A friendly reminder that this issue had no activity for 30 days. |
Issue Description
I have a Containerfile that includes a
RUN
with a bind mount to a file from a second build context specified using--build-context mycon=my_dir
to thepodman build
command. No matter what I do this step is never reused/cached and is always rerun when building. My understanding is that this shouldn't be the case.If I use the default build context and don't specify a
from=
in my RUN mount then it works fine. However even if I specify an additional build context that is the base context it fails (see below).Steps to reproduce the issue
Steps to reproduce the issue
Create directory
test_mounting
and change to it.Create
test_mounting.Containerfile
with content below.Run:
Run
podman build --log-level info -t test-mounting:latest --build-context mycon=. -f test_mounting.Containerfile .
Containerfile
The non-mounted RUN calls are just to show that things are run and cached or not cached.
Describe the results you received
Describe the results you expected
I expected the RUN with the mount to be cached. In my real world case my extra build context is not the base context and I'm using
--cache-to
and--cache-from
. The step right after this mount RUN is a lot of compiling so it is very noticeable when it isn't cached.podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
Additional information
I originally noticed this in a local gitlab CI runner, but narrowed it down to the above example.
Side question: Does file modification time invalidate the layer cache for a COPY and/or bind mount?
The text was updated successfully, but these errors were encountered: