jlesage / docker-mkvtoolnix

Docker container for MKVToolNix
MIT License
222 stars 19 forks source link

non-root image #29

Closed jr0dd closed 1 year ago

jr0dd commented 3 years ago

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.

jlesage commented 3 years ago

What do you mean exactly by non-root image ?

jr0dd commented 3 years ago

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" ]
jlesage commented 3 years ago

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.

jr0dd commented 3 years ago

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.

jlesage commented 3 years ago

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.

jernejml commented 2 years ago

I have similar wish (non-root image). Is there any progress with new base image?

jlesage commented 2 years ago

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/.

jernejml commented 2 years ago

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!

jlesage commented 1 year ago

Perfect, so I think we can close this issue.