Bug 2111275
| Summary: | Permission denied creating or accessing files in a --mount=type=cache Dockerfile with buildah | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | David Guthrie <dguthrie> |
| Component: | buildah | Assignee: | Aditya R <arajan> |
| Status: | CLOSED WORKSFORME | QA Contact: | atomic-bugs <atomic-bugs> |
| Severity: | high | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 8.6 | CC: | arajan, pthomas, tsweeney, umohnani |
| Target Milestone: | rc | Flags: | tsweeney:
needinfo-
pm-rhel: mirror+ |
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2022-08-22 21:49:17 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
David Guthrie
2022-07-26 23:00:18 UTC
@dguthrie can I ask for a few more details please? At first blush, it looks like you may have not volume mounted /mycache. Can you please let us know: 1) Were you running this a root or a rootless user 2) What was the buildah command that you used? Hi @tsweeney and @arajan
The initial command was this:
$ buildah build --layers=true -t localhost/testlayers:v1 .
I had to used --cap-add to have it allow strace. I did try it with setenforce 0 and 1. There are no messages that show up in the selinux logs.
$ buildah build --layers=true -t localhost/testlayers:v1 --cap-add SYS_PTRACE .
Okay, it does work if I set use both ",z" and set the user to root
~~~
FROM ubi8/ubi
ARG UID=0
ARG GID=0
USER ${UID}:${GID}
RUN --mount=type=cache,uid=${UID},gid=${GID},target=/mycache,z touch /mycache/test.txt
RUN --mount=type=cache,uid=${UID},gid=${GID},target=/mycache,z mkdir -p /mycache/foo/bar
~~~
If I change the user ID to something else, like 1000, it fails.
Hi @arajan,
One thing I did notice is that if I run it once with the 'z' flag, then I can thereafter take the z flag off and it will still work with that same cached path. It seems to be reusing the same cached pat, but remembering the how it was created (i.e. z) rather than treating the path with the 'z' and different than the one without.
What I mean is
RUN --mount=type=cache,uid=${UID},gid=${GID},target=/mycache touch /mycache/test.txt
-- Permission denied
RUN --mount=type=cache,uid=${UID},gid=${GID},target=/mycache,z touch /mycache/test.txt
-- Success
RUN --mount=type=cache,uid=${UID},gid=${GID},target=/mycache touch /mycache/test.txt
-- Success
Where the UID is 0, of course.
|