<p>Could you please let me know how to run a <code>gradle</code> image (pulled from <code>docker</code> repository), with <code>jib</code> plugin and running as non-<code>root</code> user in <code>Kubernetes pod</code>?</p>

<p>I have build a <code>gradle</code> image using <code>Gradle 4.6</code>. </p>

<p>I’m using this image in my <code>Kubernetes pod</code>.</p>

<p>When I run the image as user - <code>root</code>, the <code>gradle</code> build is successful. </p>

<p>When I run the image as non-<code>root</code> user (because of <code>pod RBAC</code> enablement),  the build fails as <code>gradle</code> is unable to create <code>/.gradle</code> directory and there are no sufficient privileges and getting the below error.</p>

<blockquote>
  <p>Failed to load native library 'libnative-platform.so' for Linux amd64.</p>
</blockquote>

<p>Is there any way to grant the non-<code>root</code> user passed via <code>securityContext</code> to perform the build successfully using the <code>gradle</code> image?</p>

<p>Is there a better way to resolve the issue without changing the directory permission to <code>777</code> . </p>

<p>Thanks in advance!!</p>

<p>Check if <code>/.gradle</code> directory is already created by <code>root</code></p>
<p>E.g. using <code>stat</code> command. You might see that current user doesn't have enough permissions to work with it:</p>
<pre><code>$ stat ~/.gradle | grep Uid
&gt; Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
</code></pre>
<p>If so, change owner of the directory:</p>
<pre><code>$ sudo chown -R $USER ~/.gradle
</code></pre>
<p>Where</p>
<ul>
<li><code>sudo chown -R</code> does recursive owner update</li>
<li><code>$USER</code> contains current username</li>
</ul>
