Skip to content
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

buildah bud fails silently when copying file to volume when root #5884

Open
mparada-suva opened this issue Dec 18, 2024 · 1 comment
Open

Comments

@mparada-suva
Copy link

Description

When copying a local file to a folder declared as a volume in an image using buildah bud as the root user the copy command is silently ignored.

Version

Output of buildah --version: buildah version 1.33.7 (image-spec 1.1.0-rc.5, runtime-spec 1.1.0)
Unfortunately can't update, since this is the newest available version I get from RedHat.

To reproduce

  • Have the following files locally available:

Dockerfile

FROM  jenkins/jenkins:2.490
USER root
RUN chgrp -R root /var/jenkins_home/
COPY foo.txt /var/jenkins_home
RUN cat /var/jenkins_home/foo.txt

foo.txt

just a test file

Note that the /var/jenkins_home folder is declared as a volume in the FROM image. If the same was done, say with the /tmp folder COPY would work.

  • Build with buildah bud: buildah bud -t test .

Result

STEP 1/5: FROM jenkins/jenkins:2.490
STEP 2/5: USER root
STEP 3/5: RUN chgrp -R root /var/jenkins_home/
STEP 4/5: COPY foo.txt /var/jenkins_home
STEP 5/5: RUN cat /var/jenkins_home/foo.txt
cat: /var/jenkins_home/foo.txt: No such file or directory
Error: building at STEP "RUN cat /var/jenkins_home/foo.txt": while running runtime: exit status 1

Expected result

I would expect one of the following behaviors (in order of preference):

  • COPY fails with an error that says you can't copy to a volume (since it would be overwritten once a volume is actually mounted there)
  • COPY outputs a warning saying whatever you copy to a volume will be overwritten on mount. But allows the copy to work. This would be acceptable if one knows the file is only needed at build time and can be overwritten at runtime. Looks like a footgun but at least it's a warning.
  • COPY silently works. Bigger footgun, but still acceptable.

What I don't think it is acceptable is to silently fail the COPY and simply continue building the next step.

Or maybe I'm doing something wrong 😅 If that is the case, please point me in the right direction!

@rhatdan
Copy link
Member

rhatdan commented Dec 18, 2024

What version of RHEL is this?

Is /var/jenkens_home a volume? If yes could you copy the file to /tmp and see if it shows up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants