大网数据广告活动
服务器运维问答

Which non-root user should I use on Google Kubernetes Engine?

· 52CE 我爱测

When configuring a container process to run as a non-root user on Kubernetes, does the user need to exist on the host? If yes, which user id is appropriate to use when the host node is managed by Google Kubernetes Engine? Google …

问题原文

原帖链接 · Niels Søholm · CC BY-SA 4.0

When configuring a container process to run as a non-root user on Kubernetes, does the user need to exist on the host? If yes, which user id is appropriate to use when the host node is managed by Google Kubernetes Engine?

Google Cloud's recommended best practices for operating containers state the following:

(...) it is a best practice to not run processes as root inside containers. You can enforce this behavior in Kubernetes by using a PodSecurityPolicy. When creating a pod in Kubernetes, use the runAsUser option to specify the Linux user that is running the process.

I would like to follow this practice.

已采纳解答

原帖链接 · mehdi sharifi · CC BY-SA 4.0

As mentioned in the Best Practice document, you can run a container image locally (or on GKE cluster nodes) with a random user:

docker run --user $((RANDOM+1)) [YOUR_CONTAINER]

It means the user can be a random one; so, it is not of the kind to exist on the host. You just need to make sure it is not a root.

Moreover, you can check this document and run the command to Get a shell to a running Container. After running "ps aux", you will see some processes running under the available users. They can be any random user.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。