<p>I try to deploy mongodb with helm and it gives this error:</p>
<pre><code>mkdir: cannot create directory /bitnami/mongodb/data : permision denied.
</code></pre>
<p>I also tried this solution:</p>
<pre><code>sudo chown -R 1001 /tmp/mongo
</code></pre>
<p>but it says no this directory.</p>

<p>You have permission denied on <code>/bitnami/mongodb/data</code> and you are trying to modify another path: <code>/tmp/mongo</code>. It is possible that you do not have such a directory at all.
You need to change the owner of the resource for which you don't have permissions, not random (non-related) paths :)</p>
<p>You've probably seen  <a href="https://github.com/bitnami/bitnami-docker-mongodb/issues/177" rel="nofollow noreferrer">this github issue</a> and  this answer:</p>
<blockquote>
<p>You are getting that error message because the container can't mount the /tmp/mongo directory you specified in the docker-compose.yml file.</p>
<p>As you can see in  <a href="https://github.com/bitnami/bitnami-docker-mongodb#366-r16-and-411-r9" rel="nofollow noreferrer">our changelog</a>, the container was migrated to the non-root user approach, that means that the user  <code>1001</code>  needs read/write permissions in the /tmp/mongo folder so it can be mounted and used. Can you modify the permissions in your local folder and try to launch the container again?</p>
</blockquote>
<pre><code>sudo chown -R 1001 /tmp/mongo
</code></pre>
<p>This method will work if you are going to mount the <code>/tmp/mongo</code> folder, which is actually not quite a common behavior. Look for another answer:</p>
<blockquote>
<p>Please note that mounting host path volumes is not the usual way to work with these containers. If using docker-compose, it would be using docker volumes (which already handle the permission issue), the same would apply with Kubernetes and the MongoDB helm chart, which would use the <code>securityContext</code> section to ensure the proper permissions.</p>
</blockquote>
<p>In your situation, you'll just have change owner to the path <code>/bitnami/mongodb/data</code> or to use <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" rel="nofollow noreferrer">Security Context</a> on your Helm chart and everything should work out for you.</p>
<p>Probably <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods" rel="nofollow noreferrer">here</a> you can find the most interesting part with example context:</p>
<pre class="lang-yaml prettyprint-override"><code>securityContext:
  runAsUser: 1000
  runAsGroup: 3000
  fsGroup: 2000
  fsGroupChangePolicy: &quot;OnRootMismatch&quot;
</code></pre>
