Closed jr0dd closed 1 year ago
What do you mean exactly by non-root image ?
create a new user and have that user running the container. here's a couple snippets from relevant sections of code from here https://github.com/k8s-at-home/container-images/blob/main/base/ubuntu/Dockerfile
RUN \
adduser kah \
--uid 568 \
--group \
--system \
--disabled-password \
--no-create-home \
&& \
mkdir -p /config \
&& chown -R kah:kah /config \
&& chmod -R 775 /config
ENV LANG en_US.UTF-8
USER kah
VOLUME [ "/config" ]
Ok, then the image is almost already non-root. Currently, the app itself (MKVToolNix) is running as non-root, along with most other supporting processes.
Note that I'm also working on the next version of the baseimage, in which s6-overlay is replaced by something simplier.
Very nice! It seems that a lot of images are using Tini over S6 these days. You did a great job on this btw. I did create a helm chart for this to use on k8s clusters. I'll wait to push it to my git if you're working on a new base image anyways.
Tini is good at running a single process. But it is not a process manager, which is something required for complex Docker image like this one, where multiple processes are running inside the container.
I have similar wish (non-root image). Is there any progress with new base image?
Yes, I'm hoping to start deploying apps based on the new baseimage in the following days/weeks.
To set expectations about non-root images: the new baseimage run all processes under a non-root user, except for the process monitor and init scripts, who still needs to be run as root. As mentioned earlier, the method used by containers under the k8s-at-home
repo doesn't apply here. k8s-at-home
applications are single binaries that don't need external services to function.
To be serious about all that, one should use Docker in rootless mode instead. With this mode, the whole Docker engine, along with containers, are not running as root. Docker uses a trick to remap users, meaning that the root user in the container is mapped to a non-root user on the host. See this interesting article: https://mohitgoyal.co/2021/04/14/going-rootless-with-docker-and-containers/.
Thank you for your quick reply.
Immediately after posting, I realized I actually don't really require non-root image. I only needed a different application user, and this could be achieved by passing env variables USER_ID/GROUP_ID. So, my bad, for not even carefully reading README page.
Still, your additional explanations (and the link) were very useful. Thanks again!
Perfect, so I think we can close this issue.
I would love to see a non-root image released. Check out the k8s-at-home repo. They are also moving away from S6 overlay as well which I've also noticed more container devs are moving away from.