<p>This is my pod:</p>
<pre class="lang-yaml prettyprint-override"><code>spec:
  containers:
    volumeMounts:
    - mountPath: /etc/configs/config.tmpl
      name: config-main
      readOnly: true
      subPath: config.tmpl
  volumes:
  - configMap:
      defaultMode: 420
      name: config-main
    name: config-main
</code></pre>
<p>This is my config map:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: config-main
data:
  config.tmpl: |
        # here goes my config content

</code></pre>
<p>This produces the following error:</p>
<blockquote>
<p>Error: failed to create containerd task: failed to create shim: OCI
runtime create failed: container_linux.go:380: starting container
process caused: process_linux.go:545: container init caused:
rootfs_linux.go:76: mounting
&quot;/var/lib/kubelet/pods/dc66ebd1-90ef-4c25-bb69-4b3329f61a5a/volume-subpaths/config-main/podname/1&quot;
to rootfs at &quot;/etc/configs/config.tmpl&quot; caused: mount through procfd:
not a directory: unknown</p>
</blockquote>
<p>The container has pre-existing <code>/etc/configs/config.tmpl</code> file that I want to override</p>

chingis
<p>To mount as file instead of directory try:</p>
<pre><code>spec:
  containers:
    volumeMounts:
    - mountPath: /etc/configs/config.tmpl
      name: config-main
      readOnly: true
      subPath: config.tmpl
  volumes:
  - configMap:
      defaultMode: 420
      items:
      - key: config.tmpl
        path: config.tmpl
      name: config-main
    name: config-main
</code></pre>
