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

Add privileged option #12

Open
majutsushi opened this issue May 7, 2019 · 6 comments
Open

Add privileged option #12

majutsushi opened this issue May 7, 2019 · 6 comments

Comments

@majutsushi
Copy link

--privileged is the only Docker switch currently needed by our build process in floki. With the recent change to require the "local" option if Docker switches are used it would be useful if that could be an option instead.

@rlupton20
Copy link
Collaborator

Seems pretty reasonable. The dind container runs with privileged, and I think in general this should be fine for reproducibility. I'll have a quick look over the docker Docs to see if to entails anything interesting, and probably knock it together in the next few days.

Just for my interest, and if you can disclose, what kind of thing do you need the privileged flag for?

@majutsushi
Copy link
Author

majutsushi commented May 8, 2019

Thanks! We need it to be able to manage loopback devices so the "virtualize" tool can run.

@rlupton20
Copy link
Collaborator

rlupton20 commented May 25, 2019

Just taking a look into this at the moment. I'm trying to understand what's really needed here. In general floki tries to avoid anything which makes the container environment reflect the host (without explicit checks, like with ssh-agent sockets) to help guarantee that the container environment is as consistent and host independent as possible. The privileged flag basically makes /dev host dependent.

Secondly, I've built some images before using loopback devices in a container (not for Metaswitch products - I think I was building my own mini-linux image by hand, as one does), and using privileged containers means your loopback setups persist over container lifetime (essentially escape the sandbox). This is also kind of a usability pain.

I think I want to figure out how to do this, but I'm not convinced that priviliged is the way to go. I think the next step is to figure out if it's possible to get loopback devices working in a full container (perhaps mknod can do this?), and if that's not possible, what minimal set of permissions are needed. Loopback devices are also a little annoying because, IIRC, they need a kernel module which most systems don't have activated by default. Containers sit on top of the kernel of course, so this isn't something that's namespaced as such (I think). Probably we need a nice usable way to feed that information back to the user.

More broadly, whats the general case here? I'm not sure loopback specific function is the way to go, but if we can figure out the right way to capture it generically, with a suitable reproducibility story, I can add that as the happy path feature.

Interested in your thoughts!

@mviereck
Copy link

mviereck commented Aug 4, 2019

I just stumbled about this and don't understand all implications, so please excuse me if I am totally wrong.

If the loopback device setup needs somehow mount, than capability --cap-add=SYS_ADMIN would be enough instead of --privileged. However, this capability is powerful and can be abused in a container.

If the loopback device setup rather needs networking capabilities, one of NET_ADMIN or NET_BROADCAST might help.

Compare: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities

@rlupton20
Copy link
Collaborator

@mviereck thanks - yeah, I think the precise permissions need to be understood.

This refers to mounting of loopback block devices (/dev/loop0 etc) from the host device. Essentially the game here is providing enough that the device is easy to access and use, yet at the same time not making too many assumptions about the host (floki is a build tool, and it's mainline use case is to be run after a git clone to get a build environment - it ought not to be tied to details of the host).

Loopback devices are fun because they need a kernel module that isn't loaded by default. In general, I probably need to think about how to solve these kinds of problems.

@maxdymond
Copy link
Collaborator

Might be unnecessary now that docker_switches works by default.

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

4 participants