-
Notifications
You must be signed in to change notification settings - Fork 8
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
sudo fails to run in k8s #14
Comments
Hi @telmich, i'm agree about the UID 0 but if we do that, it's will generate a breaking change if any dependent image have a Dockerfile ended by |
Good morning @mistraloz! I think the I have seen that your back/front containers are separated, but they are derived from the same base image. If you want to avoid breaking existing users, I'd suggest the following:
If you happen to have a chat (slack, matrix, etc.) I can also join there, as I would be open to some improvements, maybe even supporting an -alpine version. |
1/ If you know how to create one without required of sudo usage, do it, it's the best way :). I'm not available for 3hours but after i may discuss with you by chat if you are available. |
In fact, in Kubernetes, by default, you cannot use "sudo" in the containers unless you explicitly allow privilege escalation (which is documented here: https://github.com/thecodingmachine/docker-images-nodejs#usage-in-kubernetes ) Indeed, we do this for Docker environments, so that the running user in Docker is the same as the current user of the OS (which is helpful if your process is writing files). I'm not 100% sure making a variant of the image is the way to go. Because if you build images on top of those images, you will have to make several variants. The best possible solution would be to be able to detect (somehow, I don't really know how), that we are running in Kubernetes and to avoid using "sudo" in this case. If we can detect that the "/usr/src/app" directory is NOT mounted (but part of the image itself), then there is no point in changing the user ID dynamically as we do, and therefore, no point in running sudo ? |
I prefer staying slim/keeping the number of variants down, @moufmouf, but due to the way how the image is built, by default the userid is set to docker at the moment. We did patch our way around this by using
So on entrance point, the user is already set to docker by default and if the image is not changed, you cannot easily revert this. In other words: to be k8s native, the image will need to not switch away user in the first place, which is currently part of the Dockerfile. Does it make sense? |
Comparing with https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.14-apache:
could be removed and additionally the entrypoint scripts could either be modified or a new one that is made for running without sudo could be added. It might be possible to create the image like this and use docker-compose with the |
I'm not sure but this part may not require any changes. I think the mandatory changes are here
So to make a PR who accept to be run without sudoers, I think we have to :
|
The item "Find a solution to run a2enmod as docker user" can be easily solved by
in the Dockerfile. In regards to autodetection vs. |
I'm suspicious of solutions that seem too easy :p ... but you have right, it's seem to be the only need. Can you make a PR for that ? I'm will be on holidays and make changes during the christmas sales may be not a good idea but i can merge that early january. |
I don't know how far it is related but I was able to reproduce the same sudo issue with debian:stretch-slim, on which this image is based, and fixing it by using debian:bullseye-slim instead. Could it be that upgrading the base for the image would fix the issue? |
When trying to run
thecodingmachine/workadventure-front:v1.6.4
it fails with:Changing the cmd to shell and testing manually:
Seeing that the initial script switches directly to execute
sudo tini
, I wonder if it wouldn't make sense to...The text was updated successfully, but these errors were encountered: