问题原文
原帖链接 · 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
