<p>I have added a security context in my pod which looks as follows:</p>

<pre><code>spec:
  securityContext:
    runAsNonRoot: true
</code></pre>

<p>While running the pod I am getting error message (kubectl get pod pod-name -o=yaml):</p>

<blockquote>
  <p>container has runAsNonRoot and image has non-numeric user (default),
            cannot verify user is non-root</p>
</blockquote>

<p>The message is intuitive but, after reading this <a href="https://kubernetes.io/blog/2016/08/security-best-practices-kubernetes-deployment/" rel="noreferrer">kubernetes blog</a> it seems to me it should be very straight forward, what I am missing here?</p>

<p>This error comes only when your uid == nil,. Based on the error text, we need to set a numeric user value.</p>

<p>So, for the user with UID=1000 you can do it in your pod definition like:</p>

<pre><code>securityContext:
  runAsUser: 1000
</code></pre>

<p>So your <code>securityContext</code> should be like:</p>

<pre><code>securityContext:
  fsGroup: 2000
  runAsNonRoot: true
  runAsUser: 1000
</code></pre>

<p>Checkout it in official docs <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod" rel="noreferrer">here</a></p>
