-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create images with a built-in non-root user #1029
Comments
Hi @cjvogel1972 , thanks for suggesting this and providing the detailed explanation! We'll look into adding this option @GoogleContainerTools/java-tools We will probably add a |
@mattmoor any thoughts on this? |
UPDATE: specifying names will work just as much as numbers work; there's no need to translate names to numbers at image build time. Names will be set in the container configuration JSON as-is, and it's a fair game at runtime whether a name works or not, which is also the case with
FROM ubuntu
USER chanseok
CMD ls
One way to make this work with FROM ubuntu
RUN groupadd --non-unique --gid 23456 awesomegroup
RUN useradd --non-unique --system --uid 12345 --gid 23456 chanseok
USER chanseok
ENTRYPOINT ["cat", "/etc/group", "/etc/passwd"] |
Where I work, we run our containers with real generic IDs and groups. And we use the real UID and GID associated with them. We add the information to the image through either |
A configurable user would indeed be very nice. I need a "fixed" uid because some of my applications need to mount a kubernetes volumes and I have to setup the access privileges according to the user of the docker image (if it is a non root user). |
So the current plan will be to add the Example: <container>
...
<user>1000</user>
</container> |
Should not forget to do something about our |
Interested people can include custom
|
#1109 fixes this. There is no restriction in specifying the user with |
Hi, sorry that I am new to docker and k8s. I wonder what steps to do to follow the security best practices? My naive thought:
IMHO the best practice said everywhere is to use non-root user. So jib may have some built-in methods to do so. But I did not find the doc. Thanks very much! |
@fzyzcjy almost all Linux distros have the All in all, choosing and selecting the right user depends on what users are defined in your base image and how your application will work as a non-root user. |
@chanseokoh Thanks very much! I will have a try |
Description of the issue:
Best practices for Docker containers is to run them as a non-root user. As Jib works now, there is no way to specify a built-in non-root user. Google distroless gives an example of how to do this using Bazel.
I saw your answer for issue #631, but that I don't think that limits the security risk. In Docker, you have to remember to add the --user in the run command. You Kubernetes security context answer helps, but it still requires you to remember to set the configuration.
I just think it would be good if the tool gives the option to build the user ID into the image. Just as an example, where I work, neither solution would work because we have security software that inspects the image and prevents its use if there is not a user ID built into the image. I would love to use Jib at work, but until the user ID is baked into the image, it won't be possible.
Expected behavior:
It would be good to add to the jib/to closure an option for specifying a user and group to run the container as.
The text was updated successfully, but these errors were encountered: