cloudnativedevops / demo

Simple demonstration app for 'Cloud Native Devops'
MIT License
799 stars 517 forks source link

Error: container has runAsNonRoot and image will run as root #31

Open PieperCH opened 4 years ago

PieperCH commented 4 years ago

Hi all,

deploying the hello-k8s simple demo app to our PKS kubernetes cluster shows this error in

C:\kubectl describe po demo-b579d8cb6-25lvv

Warning Failed 5s (x3 over 37s) kubelet, ab58d759-e5ad-4f5c-8a84-8039c0181301 Error: container has runAsNonRoot and image will run as root

What is wrong here in the image?

Regards, Christian

bitfield commented 4 years ago

Nothing's wrong as such, but Kubernetes is saying you have a PodSecurityContext that specifies the container must not run as root, and the default in Docker containers if you don't specify a user is to run as root. I don't think we specify runAsNonRoot anywhere in the k8s manifests, so this may be a local config issue with your cluster or provider. (Personally, I think defaulting to runAsNonRoot is an awfully good idea, so I wouldn't change it—but just be aware there will be a similar issue running almost any Docker image unless you specify a non-root user for it.)