Inside container's mount path Folder no file present only lost+found directory

We have scenario where we are building the image Dockerfile where inside Dockerfile we are copying the local folder into the image one is code folder and another is product folder /apps/pub/crx-quickstart and this path is mounted with local storage. when i am creating a POD inside kubernetes cluster inside mount path /apps/pub/crx-quickstart no files and folder and it is showing lost+found directory.

I am struggling from last 3 days and unable to solve it. Please help

1 Like

I’m afraid that it’s normal behavior. If you mount something to the path the original content will be hidden. There is nothing to merge your data from the docker image with the data on the volume. Do you try mounting it as a sub-dir of /apps/pub/crx-quickstart?

Here is the snippets

Creating a Statefulset

    volumeMounts:
    - name: publisher
      mountPath: /apps/publisher/crx-quickstart
    env:

volumeClaimTemplates:

  • metadata:
    name: publisher
    spec:
    accessModes: [ “ReadWriteOnce” ]
    resources:
    requests:
    storage: 100Gi

So this /apps/publisher/crx-quickstart will mount inside the POD and all the content should be visible but nothing is coming inside.

It looks correct for me. You mount the empty,100Gi volume to /apps/publisher/crx-quickstart. If you have some files there they are “covered” by this mount.

But it is not happening inside the container when i am going and doing ls -ltr only one directory lost+found is present. even though inside the container it has mounted well

Interesting… it looks like you hit the difference between K8s and docker volumes implementations.

Docker: https://docs.docker.com/storage/volumes/#populate-a-volume-using-a-container

K8s: I’m pretty sure there is no such mechanism

@Sudip_Kumar did you manage to figure this out? We’re seeing the same thing with a StatefulSet.

You need to copy data into the volume. Whatever path you mount it on will be hidden inside your running container, regardless of whether your image has data there. Docker tries to be clever and copy files there, but Kubernetes does not - too many edge cases. You made a volume, you have to initialize it. Only you know what that really means for your app.

In our scenario the data in the volume is initialized by an entrypoint script. However, an empty directory where the data is initialized does exist before initialization happens. When we scale down the StatefulSet and then scale it back up the data is gone.