<p>I am trying to deploy a Magento app but I am getting the following error. This cluster is created on EKS and PVC is there <a href="https://i.stack.imgur.com/BLc2l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BLc2l.png" alt="enter image description here" /></a></p>
<p>persistentvolumeclaim &quot;media&quot; not found
Error: failed to start container &quot;magento-web&quot;: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused &quot;process_linux.go:449: container init caused &quot;rootfs_linux.go:58: mounting \&quot;/var/lib/kubelet/pods/8865b7dsdbd-721c-45f3-ab77-43a5f5da1362/volume-subpaths/nginx-config/magento-web/0\&quot; to rootfs \&quot;/var/lib/docker/overlay2/b1b3faa530b6sasas4ad6a9e62db641c5589fef3d29a9ab01f2db594652851a1814a6/merged\&quot; at \&quot;/var/lib/docker/overlay2/b1b3faa530b64ad6a9e62db641c5589fef3d29a9ab01fdsd2db594652851a1814a6/merged/etc/nginx/conf.d/default.conf\&quot; caused \&quot;not a directory\&quot;&quot;&quot;: unknown: 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
Back-off restarting failed container</p>
<pre><code>    apiVersion: v1
kind: Service
metadata:
  name: magento-web
  namespace: magento
  labels:
    app: magento-web
    k8s-app: magento
spec:
  ports:
  - name: &quot;http&quot;
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: magento-web

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: magento-web
  namespace: magento
  labels:
    app: magento-web
    k8s-app: magento
spec:
  selector:
    matchLabels:
      app: magento-web
  strategy:
    rollingUpdate:
      maxSurge: 50%
      maxUnavailable: 30%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: magento-web
        k8s-app: magento
    spec:
      containers:
      - image: nginx:mainline
        imagePullPolicy: Always
        name: magento-web
        ports:
        - containerPort: 80
          protocol: TCP
        resources:
          limits:
            cpu: 10m
            memory: 128Mi
          requests:
            cpu: 10m
            memory: 128Mi
        volumeMounts:
        - mountPath: /etc/nginx/conf.d/default.conf
          name: nginx-config
          subPath: default.conf
        - mountPath: /var/www/html/magento2.conf
          name: nginx-config
          subPath: magento2.conf
        - name: media
          mountPath: /var/www/html/pub/media
        - mountPath: /var/www/html/pub/static
          name: static
      volumes:
      - configMap:
          defaultMode: 420
          name: nginx
        name: nginx-config
      - name: media
        persistentVolumeClaim:
          claimName: media
      - name: static
        persistentVolumeClaim:
          claimName: static
</code></pre>
<p><strong>kubectl get pvc -n magento</strong></p>
<p><a href="https://i.stack.imgur.com/f4kaP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f4kaP.png" alt="enter image description here" /></a></p>
<pre><code>volumes:
      - configMap:
          defaultMode: 420
          name: nginx
        name: nginx-config
      - name: media
        persistentVolumeClaim:
          claimName: media
      - name: static
        persistentVolumeClaim:
          claimName: static
</code></pre>

programmer one
<p>As the error states  &quot;Are you trying to mount a directory onto a file (or vice-versa)&quot; for default.conf ,</p>
<p>The configmap usage seems incorrect , try using like this</p>
<pre><code> - configMap:
          items:
          - key: default.conf
            path: default.conf
          name: nginx
        name: nginx-config
</code></pre>
<p>Read here - <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume</a></p>
