<p>I am new to k8s. I am following <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">official tutorial</a> on setting up Nginx pods in k8s using minikube, mounting a volume and serving index.html. </p>

<p>When I mount and go to hompe page, i receive this error that 
<code>directory index of "/usr/share/nginx/html/" is forbidden</code>. </p>

<p>If I dont mount anything, i receive a "Welcome to Nginx" page. </p>

<p>This is the content of that folder before mount. And after mount is empty</p>

<pre><code>root@00c1:/usr/share/nginx/html# ls -l
total 8
-rw-r--r-- 1 root root 494 Jul 23 11:45 50x.html
-rw-r--r-- 1 root root 612 Jul 23 11:45 index.html

</code></pre>

<p>Why is mounted folder inside pod empty after mounting?</p>

<p>This is my setup </p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/home/my_username/test/html"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Mi
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-hello-rc
spec:
  replicas: 2
  selector:
    app: hello-nginx-tester
  template:
    metadata:
      labels:
        app: hello-nginx-tester
    spec:
      securityContext:
        fsGroup: 1000
      volumes:
        - name: task-pv-storage
          persistentVolumeClaim:
            claimName: task-pv-claim
      containers:
        - name: task-pv-container
          image: nginx
          ports:
            - containerPort: 80
              name: "http-server"
          volumeMounts:
            - mountPath: "/usr/share/nginx/html"
              name: task-pv-storage
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-tester
  labels:
    app: hello-nginx-tester
spec:
  type: NodePort
  ports:
  - port: 80
    nodePort: 30500
    protocol: TCP
  selector:
    app: hello-nginx-tester
</code></pre>

<p>Any info would be appreciated. thanks</p>

djulb
<p>I've checked your configuration on my running k8s environment. After some adjustments the following manifest works smoothly for me:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/home/my_username/test/html"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Mi
  volumeName: task-pv-volume
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-hello-rc
spec:
  replicas: 2
  selector:
    app: hello-nginx-tester
  template:
    metadata:
      labels:
        app: hello-nginx-tester
    spec:
      securityContext:
        fsGroup: 1000
      volumes:
        - name: task-pv-volume
          persistentVolumeClaim:
            claimName: task-pv-claim
      containers:
        - name: task-pv-container
          image: nginx
          ports:
            - containerPort: 80
              name: "http-server"
          volumeMounts:
            - mountPath: "/usr/share/nginx/html"
              name: task-pv-volume
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-tester
  labels:
    app: hello-nginx-tester
spec:
  type: NodePort
  ports:
  - port: 80
    nodePort: 30500
    protocol: TCP
  selector:
    app: hello-nginx-tester
</code></pre>
