genuinetools / img

Standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder.
https://blog.jessfraz.com/post/building-container-images-securely-on-kubernetes/
MIT License
3.88k stars 230 forks source link

Is it possible to run img as a root user in an unprivileged container? #273

Closed sreya closed 4 years ago

sreya commented 4 years ago

Running img build is easy enough given the image that @jessfraz provides, but if I modify the image such that the user is root I get the following error:

docker run -it --security-opt seccomp=unconfined --security-opt apparmor=unconfined  img-root /bin/sh
~ # img build -t foo . 
Building docker.io/library/foo:latest
Setting up the rootfs... this may take a bit.
WARN[0000] Process sandbox is not available, consider unmasking procfs:
[+] Building 0.1s (2/2) FINISHED
 => [internal] load build definition from Dockerfile                                                                                    0.1s
 => => transferring dockerfile: 77B                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                       0.1s
 => => transferring context: 2B                                                                                                         0.0s
Error: failed to solve: failed to read dockerfile: failed to mount /tmp/buildkit-mount058376101: [{Type:bind Source:/home/user/.local/share/img/runc/native/snapshots/snapshots/2 Options:[rbind ro]}]: operation not 

What is required to execute it the tool as root inside a container?

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.76. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

AkihiroSuda commented 4 years ago

see https://github.com/moby/buildkit/blob/master/docs/rootless.md#distribution-specific-hint