<p>I'm fairly new to kubernetes and docker, so be patient with me.</p>
<p>I am trying to mount a Windows share in linux which is contained in docker, which is a kubernetes pod.</p>
<p>I managed to get all the correct permissions in kubernetes and docker to mount the share manually. However I need this to be done via the Dockerfile, since it needs to be automated.</p>
<p>This is my Dockerfile:</p>
<pre><code>WORKDIR /app
COPY ./start-script.sh ./start-script.sh

RUN apt-get update &amp;&amp; apt-get install -y cifs-utils
RUN mkdir Windows-Share
# RUN mount.cifs &lt;Window share folder&gt; /app/Windows-Share/ -o username=&lt;username&gt;,password=&lt;password&gt;,domain=&lt;domain&gt;

ENTRYPOINT [&quot;bash&quot;, &quot;./start-script.sh&quot;]
</code></pre>
<p>Here is my start-script.sh:</p>
<pre><code>#!/bin/bash
mount.cifs &lt;Window share folder&gt; /app/Windows-Share/ -o username=&lt;username&gt;,password=&lt;password&gt;,domain=&lt;domain&gt;
exec dotnet &lt;dotnet dll&gt;
</code></pre>
<p>Now it should be noted that I don't have access to any of the docker commands, they are all handled by kubernetes. After kubernetes creates the pod the logs will show:</p>
<blockquote>
<p>mount error(13): Permission denied</p>
<p>Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)</p>
</blockquote>
<p>This confuses me because if I log into the kubernetes pod and run the mount command manually it mounts fine. What am I missing?</p>

kumar5
<p>I had the same issue. Mount worked on server itself, in running the images as docker container but not in running the images as kubernetes deployment. In my case it helped to add a security context to the deployment with privileges and some linux capabilities:</p>
<pre><code>securityContext:
        capabilities:
          add:
            - SYS_ADMIN
            - DAC_READ_SEARCH
            - NET_BIND_SERVICE
        privileged: true
</code></pre>
