Skip to content
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

Add ENV for app UID #4506

Closed
richlander opened this issue Mar 20, 2023 · 4 comments
Closed

Add ENV for app UID #4506

richlander opened this issue Mar 20, 2023 · 4 comments

Comments

@richlander
Copy link
Member

We had a discussion about how folks should use the new app user and whether they should use its name or UID for the USER instruction. We decided that the UID is best since it works better with the runAsNonUser Kubernetes feature.

Plan:

  • Add ENV APP_UID=64198 to runtime-deps layer
  • Encourage users to use the following pattern: USER $APP_UID

It's possible that having an ENV for the UID may be useful for other scenarios.

@karolz-ms

@tmds
Copy link
Member

tmds commented Mar 24, 2023

We decided that the UID is best since it works better with the runAsNonUser Kubernetes feature.

@richlander can you elaborate what this means?

@richlander
Copy link
Member Author

richlander commented Mar 24, 2023

Per my observations:

  • Kubernetes enables you to set and/or test the container user.
  • Kubernetes only knows about UIDs.
  • If you test the user with runAsNonUser but don't set the user in Kubernetes and set the container as a non-root user by name in your Dockerfile, then that test will fail.

Do you observe same?

@richlander
Copy link
Member Author

You can use these samples to test: #4502

@tmds
Copy link
Member

tmds commented Mar 24, 2023

#4502

This has the answer I was looking for: for runAsNonRoot: true to work, you need to use the USER <uid> format. Then Kubernetes checks rootless as: UID != 0. If you use the USER <name> format, then Kubernetes can't figure out <name> isn't root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants