Skip to content

Launching a container with an unprivileged user #3225

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

Open
chyundunovDatamonsters opened this issue May 12, 2025 · 1 comment
Open

Launching a container with an unprivileged user #3225

chyundunovDatamonsters opened this issue May 12, 2025 · 1 comment

Comments

@chyundunovDatamonsters
Copy link

chyundunovDatamonsters commented May 12, 2025

Feature request

The TGI container is currently running with the root user. It is not a good practice to run in productive environments. It is suggested to run the container using a user other than root - create it when building the image.
I used this solution:

FROM ghcr.io/huggingface/text-generation-inference:3.0.0-rocm
RUN groupadd --gid 2000 user \
&& useradd --uid 2000 --gid user --shell /bin/bash --create-home user
RUN usermod -a -G video,render user
USER root
RUN chown user:user /tgi-entrypoint.sh
USER user
RUN chmod +x /tgi-entrypoint.sh
ENTRYPOINT ["/tgi-entrypoint.sh"]

Motivation

It is highly advisable to use a non-root user to run containers in productive environments.

Your contribution

FROM ghcr.io/huggingface/text-generation-inference:3.0.0-rocm
RUN groupadd --gid 2000 user \
&& useradd --uid 2000 --gid user --shell /bin/bash --create-home user
RUN usermod -a -G video,render user
USER root
RUN chown user:user /tgi-entrypoint.sh
USER user
RUN chmod +x /tgi-entrypoint.sh
ENTRYPOINT ["/tgi-entrypoint.sh"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants