<p>I have a single file which I want to mount in the container. The file is present in <code>conf</code> folder which also contains other file but the file I only want to mount is <code>helper.conf</code>. Doing this in docker:</p>

<pre><code>docker run -it -v /path/to/dir/:/path/inside/container --name mycontainer dockerimage
</code></pre>

<p>Doing this throws below error:</p>

<blockquote>
  <p>Are you trying to mount a directory onto a file (or vice-versa)? Check
  if the specified host path exists and is the expected type</p>
</blockquote>

<p>To resolve this, I created another folder with name <code>config</code> inside <code>conf</code> and used below line:</p>

<pre><code>docker run -it -v /path/to/dir/config:/path/inside/container --name mycontainer dockerimage
</code></pre>

<p>This works perfectly fine. Same is happening with <code>kubernetes</code>. Is it not possible to just mount a single file from a directory where other files are also present. Am I using wrong keywords for this.?</p>

<p>How can I resolve in Kubernetes?</p>

S Andrew
<p>The answer has been provided by @<a href="https://stackoverflow.com/users/9705485/ryan-dawson" title="486 reputation">Ryan Dawson</a>. </p>

<p>The best way to mount a single file in container (in Kubernetes) would be to use ConfigMap:</p>

<blockquote>
  <p>ConfigMaps allow you to decouple configuration artifacts from image
  content to keep containerized applications portable.</p>
</blockquote>

<p>ConfigMap can be used in this case to create a resource which will allow us to keep the configuration separate from the container image. As the configuration is a set of key-value pairs, it will allow to expose it as an environment variable that can be put inside the container or a volume. After creating ConfigMap, you will have to create a pod where you  specify a ConfigMap it can consume to get necessary values. 
In your situation, as <a href="https://stackoverflow.com/users/316857/joel-b">Joel B</a> and <a href="https://stackoverflow.com/users/2490986/tommy-nguyen">Tommy Nguyen</a> specified in this Stack Overflow <a href="https://stackoverflow.com/questions/33415913/whats-the-best-way-to-share-mount-one-file-into-a-pod/43404857#43404857">question</a> :</p>

<blockquote>
  <p>You could use subPath like this to mount single file into existing directory.</p>
</blockquote>
