Skip to content

Volume Mount Failure

Error message

                MountVolume.SetUp failed for volume: path does not exist
              

Quick summary

The container cannot mount a volume, usually because the source path does not exist, permissions are wrong, or the volume type is misconfigured.

Why this happens

  • The host path specified in a hostPath volume does not exist on the node

  • The PersistentVolume or PersistentVolumeClaim does not exist or is not bound

  • Insufficient permissions to read or write the volume mount path

  • The volume type is not supported on the node's operating system

Minimal example

✗ Broken code
volumes:
  - name: data
    hostPath:
      path: /data/app  # path does not exist on host
✓ Fixed code
volumes:
  - name: data
    hostPath:
      path: /data/app
      type: DirectoryOrCreate  # creates if missing

The broken code fails because the host path does not exist. The fix uses DirectoryOrCreate to create it automatically.

How to diagnose

  • Check the Pod events with kubectl describe pod <pod-name>

  • Verify the volume and mount paths in the Pod spec

  • Check if the hostPath exists on the node: ls /path/to/volume

  • Verify PVC status: kubectl get pvc <pvc-name>

How to fix

  • Create the missing host directory: mkdir -p /path/to/volume

  • Fix the volume name or path in the Pod spec to match the actual resource

  • Ensure the PersistentVolumeClaim is bound before deploying the Pod

  • Fix file permissions on the host: chmod 755 /path/to/volume

How to prevent

  • Use PersistentVolumeClaims instead of hostPath for production

  • Verify volume resources exist before deploying Pods

  • Use init containers to prepare volume directories

Related Resources

Related Glossary

← Back to language