<p>I have created a container which is basically a directory containing configuration files. These configuration files will be used by another container which contains the application executables.
Both the containers are deployed in the same pod.</p>
<p>I have created the pv and pvc for the 1st container like -</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: app-pv
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /mnt/data
    type: DirectoryOrCreate
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-pvc
  labels:
    type: local
spec:
  storageClassName: standard
  volumeName: app-pv
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

</code></pre>
<p>Next I am creating the deployment of both the containers like -</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app: app
spec:
  selector:
     matchLabels:
       app: app
  strategy:
     type: Recreate
  template:
     metadata:
       labels:
         app: app
     spec:
       containers:
         - name: lshome
           image: &lt;local_registry&gt;/container1:latest
           imagePullPolicy: Always
           volumeMounts:
              - name: container1-persistant-storage
                mountPath: /home/app/config
         - name: wildfly
           image: &lt;local_registry&gt;/container2:latest
           imagePullPolicy: Always
           volumeMounts:
              - name: container1-config
                mountPath: /home/app/config                 
       volumes:
        - name: container1-persistant-storage
          persistentVolumeClaim:
            claimName: app-pvc
        - name: container1-config
          persistentVolumeClaim:
            claimName: app-pvc

</code></pre>
<p>What I want is that the data under /home/app/config directory in container 1 be available to container 2 at the same directory structure. I have created the same directory structure in container 2 as well.</p>
<p>When I am trying to create the deployment, its giving the message - Unable to attach or mount volumes and then not able to create the deployment.</p>

Toulick
<p>Don't define two volumes, delete <strong>container1-config</strong> and it works. Like below.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app: app
spec:
  selector:
     matchLabels:
       app: app
  strategy:
     type: Recreate
  template:
     metadata:
       labels:
         app: app
     spec:
       containers:
         - name: lshome
           image: &lt;local_registry&gt;/container1:latest
           imagePullPolicy: Always
           volumeMounts:
              - name: container1-persistant-storage
                mountPath: /home/app/config
         - name: wildfly
           image: &lt;local_registry&gt;/container2:latest
           imagePullPolicy: Always
           volumeMounts:
              - name: container1-persistant-storage
                mountPath: /home/app/config                 
       volumes:
        - name: container1-persistant-storage
          persistentVolumeClaim:
            claimName: app-pvc
</code></pre>
