<p>I'm trying to use a directory config map as a mounted volume inside of my docker container running a spring boot application. I am passing some of the mounted paths to the things like the spring application.yaml, but it doesn't appear the mount is working as expected as it can't find the config. For example</p>

<p>Create the configmap like so</p>

<pre><code>kubectl create configmap example-config-dir \
 --from-file=/example/config/
</code></pre>

<p>Kubernetes yaml</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: example
  labels:
   app: example
spec:
  replicas: 1
  selector:
   matchLabels:
     app: example
  template:
    metadata:
      labels:
        app: example
    spec:
     containers:
     - name: example
       image: example:latest
       ports:
         - containerPort: 8443
       volumeMounts:
          - name: config-vol
            mountPath: /config
     volumes:
       - name: config-vol
         configMap:
           name: example-config-dir
</code></pre>

<p>And the Dockerfile (there are other steps which copy the jar file in which I haven't detailed)</p>

<pre><code>VOLUME /tmp
RUN echo "java -Dspring.config.location=file:///config/ -jar myjarfile.jar" &gt; ./start-spring-boot-app.sh"
CMD ["sh", "start-spring-boot-app.sh"]
</code></pre>

<p>As explained in <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-directories" rel="nofollow noreferrer">Create ConfigMaps from Directories</a> and <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files" rel="nofollow noreferrer">Create ConfigMaps from files</a>, when you create a ConfigMap using <code>--from-file</code>, <strong>the filename becomes a key stored in the data section of the ConfigMap</strong>. The file contents become the key’s value.</p>

<p>To do the way you want, a better way would be creating the yml like this</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: special-config
  namespace: default
data:
  SPECIAL_LEVEL: very
  SPECIAL_TYPE: charm
</code></pre>

<p>and then apply like this:</p>

<pre><code>kubectl create -f https://k8s.io/examples/configmap/configmap-multikeys.yaml
</code></pre>

<p>When the pod runs, the command <code>ls /config</code> produces the output below:</p>

<pre><code>special.level
special.type
</code></pre>

<p>The way you did, should generate a file with same name as your original files and within it the contents of the file.</p>
