-
Notifications
You must be signed in to change notification settings - Fork 443
MDEV-25497 now you can run "docker-entrypoint.sh mysqld --user=root" and it will work #348
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
Conversation
… work -fix for scenario when running the container in a multi-tenant, HPC environment with singularity where container root does not have full privileges and commands like "chown" will halt the script with permission denied errors
this allows for running with singularity's --fakeroot option. Before, running docker-entrypoint.sh would ignore the --user=root option needed for this to work |
Thanks for the contribution! ✨ There's a lot of "how" here, but I feel like we're missing the underlying "why" -- can you elaborate on your use case? Why do you need |
Thank you for your attention to this. I'm glad you're asking, as we may find a better path. In my case, I have a requirement to run the container as singularity's fakeroot. As I do not own the machine, I cannot run as a true root. Fakeroot, however, allows me to establish the fakeroot network for inter-container communication*; mariadb has a natural place in this pod. *Additional admin configuration necessary Running as root has the undesired consequence of triggering these two snippets in the docker-entrypoint.sh https://github.com/docker-library/mariadb/blob/master/10.5/docker-entrypoint.sh#L153
https://github.com/docker-library/mariadb/blob/master/10.5/docker-entrypoint.sh#L325
The unexpected outcome is that although root is calling this script, root does not have the permissions you might typically associate with root because it is a fakeroot with only the permissions of the user launching the container (me). chown fails. I believe when I ran However, when I would run I do realize that this request is a rather patchy, inelegant approach, but I could not see a clearer path forward. Perhaps you see a better alternative |
Thanks for providing more details!
I think this is the part I need more elaboration on -- why do you need to run as (fake)root? Why not run directly as a non-root user instead? If you (or singularity) can fix the permissions of your data directory / volume, you should be able to run as a non-root user natively (see #59 for the initial PR which provided that ability). |
Interesting question. Singularity containers by default are read-only with no rwX permission modification, though both are configurable in the build step. My original container allows writing, but not read-write permission modification, so just now I rebuilt the container to allow for rwX permission mods with the "--fix-perms" flag. However, I still get an error because I believe the mariadb container itself does not give permissions to non-root users to change directory permissions. The error occurs on /var/lib/mysql/, which I am not mounting as a data volume, so this issue cannot be related to my user permissions or to singularity's permissions. Furthermore, if I did mount this volume, I would especially not have the permission to modify the permissions as it would then be located in the host machine space. Scenarios:
So I'm still a fan of scenario 1, though I'm glad I tried the others. Can you explain the aversion to running as root in the scenario? |
I do not mean using Doing so successfully will cause the script to no longer attempt to adjust permissions at all. The aversion to running as root is because it's frankly a really bad idea in the general case (even if in the case of fakeroot it's arguably ~safe), and in order to support it for the uncommon use case of fakeroot, we have to add support for it generally (because we can't really differentiate). What we do not want to do is encourage non-fakeroot users to use this functionality. |
It actually sounds like it might not run as |
Thanks for the explanation, that makes sense. The output with command
So fakeroot really does pose as root, but the singularity runner still restricts its permissions I ran into the errors without running as fakeroot some time ago, but it's essentially required for my application. I think it fails to create the portmappings I request on the command line. Singularity does not create networks by default, you cannot create networks as a non-root user, but you can create a fakeroot network. This is the only network non-root users can create. From here, you still need the admin to customize the fakeroot network configuration file to allow for inter-container communication. It is a bit odd that creating this network and running the container as a fakeroot are tied together, but they are. I do not believe I can split the two apart. In other words, I can only run mariadb in singularity as fakeroot, which precludes me from running as anything else. I may be wrong on this point, but this has been my experience and understanding from reading/working through their docs/forums. |
Without fakeroot |
By using a volume for the datadir, and using Starting as non-root.
Client connection from the host:
Datadir looks like:
Sorry for delayed response @briveramelo, I missed that singularity was available as a package. I haven't done anything changing the standard install. I hope this works for you or whoever comes across this next. |
-fix for scenario when running the container in a multi-tenant, HPC environment with singularity where container root does not have full privileges ie: commands like "chown" will halt the script with permission denied errors