-
Notifications
You must be signed in to change notification settings - Fork 6
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
running lokinet with user namespace isolation enabled. #13
Comments
yeah i dont have enough skill in my docker foo to know that it needs. primarily i went with running debian with systemd running lokinet jammed inside a docker image. any input on making this would is greatly appreciated. |
I'll try to figure it out and wouldn't mind helping on the docker/scripting side of things. I'm not familiar with the lokinet architecture and I'm trying to figure out where |
Could you please explain why/how you use systemd inside the container? Looking into things deeper the problem seems to be because of a cgroup2/docker incompatibility and it seems a fair bit more complex than what I expected. Is there a way to execute things without systemd? |
systemd provides a bunch of nice things and is very very good at managing processes as an init.
i am sure there is, i just never spent time to set it up as docker images are an experiment that used to work at one time but is unmaintained. |
Could you please link me? I am not sure if you "need" systemd but there are lighter init systems out there. It really depends what you are using systemd for, systemd has some major advantages if you want to do advanced things (watching sockets or weird things like that). I'm having a tough time sifting through the lokinet code (not particularly good at c++ and some direction would be nice. I not finding the section of code that writes unit files and what they do etc. |
oh no we absolutely dont NEED systemd, i just thought doing that would have been easier as we already have stuff for it and such was very robust in our prod setups. it wasnt easier, so i gave up and left it broken. |
So I made some progress and was able to start the container but I still have a ton of systemd related errors; Can you confirm which of those are needed or that I can safely disable/remove/ignore?
the lokinet service also failed ...
However running the executable directly
|
you dont NEED to, you just need to make sure lokinet is configured to not die hard when you have no ipv6 supported in the kernel, i forget the default behavior but i know we have a config option that does this.
in your kind of setup? not really. systemd-resolved made our lives easier when setting dns on a systemd based linux.
oh yeah, totally. this warning can be safely ignored if you dont use resolved to set dns.
both. in your use case static dns is fine and this behavior is not relevant. only send .loki and .snode queries to it as that is what is toggled by exit routes being added, it will tunnel all dns in exit mode with resolved. if you are using dnsmasq for dns i have some config snippets for that. |
the ipv6 config snippet you need is:
yes, a blank |
you could probably just run lokinet with some super simple thing like runit if that is the literal only thing in that container. |
or... just flat out run lokinet in foreground with a docker RUN directive. the issue is that will need privs and i dont like running things as root when they CAN run without root. especially inside docker. docker's security model is... bizare. the docker group is basically one giant root privesc. never understood how their security is supposed to work. |
The more I look at it, the more I want to try to compile it on an an alpine image and strip down the whole systemd dependencies and lock things down.
Yea it is until you wrap your head around it. My daemon config below uses the userns feature - which is basically "rootless" docker. There are a bunch of advantages mostly when it comes to security and priv escalation. For non privileged containers, that means that inside the container you are root but in reality you're just being remapped and breaking out of the container would be almost impossible. cat /etc/docker/daemon.json
In our context, it will require special permissions which may mean using privileged mode and a host namespace. Because of that, systemd makes the attack surface much larger /w root access on the host which pretty much defeats my entire purpose of locking down the system. Because of the errors that I am seeing, it makes more sense to simply get rid of what's not absolutely needed, systemd is trying to "mount" the following:
Trying to tweak and reverse the whole thing is quite a pain and I've been trying multiple configuration options, mounting volumes, devices, changing c_group parameters and messing about with cap_add - and most of it due to systemd wanting to do things we don't really need to do.
As you can see my compose file is pretty messy and I haven't cleared the errors quite yet. I believe the better approach would be to build from source on a smaller image (alpine) and work entirely without systemd. This is probably going to be a fairly demanding task since I've noticed a few things that could certainly get optimized/automated/and tightened up e.g (use of python and perl in scripts, running under a different user, dropping capabilities, using wrapper scripts/environment variables for configuration among other things) @majestrate I can probably do it, but it would definitely help a lot if I could see your previous abandoned code and maybe get some assistance with building from source if you are willing to assist me with that. |
Hey there. I am experimenting with this project and I was hoping to run lokinet on my restricted docker system some of my homelab services and limit some access through lokinet only and also run a few private exit nodes. I'm running into some funky errors despite setting up my compose to use host ns, I think i may need more cap_add entries? I'm not quite sure what the container needs though.
I've also tried tweaking the example compose file to match system volumes with ro/rw; the container starts and fails
The text was updated successfully, but these errors were encountered: