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

Permission denied while running buildah image with docker #2098

Closed
danifv opened this issue Jan 20, 2020 · 12 comments
Closed

Permission denied while running buildah image with docker #2098

danifv opened this issue Jan 20, 2020 · 12 comments

Comments

@danifv
Copy link

danifv commented Jan 20, 2020

Description

I can't get the buildah images working with the docker runtime without --privileged.
Unfortunately I can't change the container runtime but nevertheless I would prefer to use an unprivileged container for building instead of dind containers with a mounted socket.

Steps to reproduce the issue:

  1. Ensure that "unshare" is allowed in your seccomp profile
  2. Start a container with docker run --rm -it --security-opt seccomp=/usr/share/containers/seccomp.json -v quay.io/buildah/stable:v.1.12.0 sh
  3. Start a buildah command e.g. buildah from alpine

Describe the results you received:

permission denied  
ERRO exit status 1

Describe the results you expected:
The image being pulled

Output of uname -a:

5.0.0-38-generic
@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2020

We really can do nothing to fix Docker daemon or the seccomp.json packaged for it.

@danifv
Copy link
Author

danifv commented Jan 20, 2020

That's clear, I was just thinking if there's a configuration option for buildah which allows it to work with whatever constraints docker applies.

@vrothberg
Copy link
Member

@danifv you can try setting BUILDAH_ISOLATION=chroot in the container's environment. This way, Buildah will use chroot instead of setting up a user namespace.

@danifv
Copy link
Author

danifv commented Jan 20, 2020

@danifv you can try setting BUILDAH_ISOLATION=chroot in the container's environment. This way, Buildah will use chroot instead of setting up a user namespace.

Unfortunately nothing changed - the error is the same.
Is there a way to get a more verbose error description?

@vrothberg
Copy link
Member

@danifv, can you try without manually changing the seccomp profile?

I am running Docker 18.09.8 on Fedora 31 and docker run --rm -it quay.io/buildah/stable:v1.12.0 sh does not error out.

@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2020

I believe buildah package attempts to create a user namespace so that it can mount the file systems. If Docker is blocking the unshare syscall,it will block buildah,

@danifv
Copy link
Author

danifv commented Jan 21, 2020

As @rhatdan pointed out unshare is needed, I get a

Error during unshare(CLONE_NEWUSER): Operation not permitted
ERRO error parsing PID "": strconv.Atoi: parsing "": invalid syntax 
ERRO (unable to determine exit status)    

when I start a buildah command if I don't enable it.
Starting the container works properly, it's using buildah inside of it that I'm struggling with.

As the buildah image works properly with the podman runtime and I can get it working properly with docker if I add --privileged (and unshare to the seccomp profile), I wonder what other permissions it needs which are unneeded when using podman but are to be explicitly set with docker.

@rhatdan
Copy link
Member

rhatdan commented Jan 24, 2020

You should be able to get this work by disabling seccomp rules.

--security-opt seccomp=unconfined
Don't need to disable all protections.

@danifv
Copy link
Author

danifv commented Jan 28, 2020

@rhatdan unfortunately this wan't enough, but in the end through some laborious yet rewarding debugging I found that restrictions for mount have to be relaxed in both seccomp and apparmor.
Thank you for your help though!
For reference, unshare was enabled from the beginning as mentioned in the original issue.

I realize that this issue board is for buildah, but if this doesn't violate any guidelines, I'd highly appreciate if any of you can share why these are enabled by default in podman and what it uses in place of apparmor.
I'm quite new to these topics and would really like to understand better the design of these components.

@TomSweeneyRedHat
Copy link
Member

@rhatdan can you reply to danifv and close this out please?

@rhatdan
Copy link
Member

rhatdan commented Aug 5, 2020

Buildah right now uses SELinux depending if it is available, we could support apparmor, if someone in the community wanted to add it.

@rhatdan rhatdan closed this as completed Aug 5, 2020
@kvaps
Copy link

kvaps commented Aug 31, 2022

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants