0

There is an application in DockerHub and the working directory is ENTRYPOINT /home/django/start.sh

I want to add a persistent volume for /home/django foler but when I add it, it can't find start.sh in the logs of the pod. How should I integrate this. I am adding the lines I added to the following kubernetes deployment file.

        volumeMounts:
        - name: django-persistent-storage
          mountPath: /home/django/
      volumes:
      - name: django-persistent-storage
        persistentVolumeClaim:
          claimName: django-pv-claim

Logs:

Error: failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/home/django/start.sh": stat /home/django/start.sh: no such file or directory: unknown

This side is not very clear to me. I would like to know exactly what I'm missing. And how can I move the app to persistent volume?

1 Answer 1

0

If your ENTRYPOINT is /home/django/start.sh and you are mounting a volume on home/django, that's going to mask the contents of the /home/django directory. That means anything included in that directory (and its children) will be inaccessible in the running container. This isn't Kubernetes-specific; this is exactly how the mount operation behaves in general.

In general, the solution is to redesign your application to separate the static code from runtime resources, and have the application initialize the runtime directories when it starts up.

If you're not able to modify the application, you may be able to accomplish your goal by using an init container to copy the contents of /home/django into your volume. That process works by (a) first spawning an init container with the volume mounted at a different location (e.g., /target), (b) having the init container run a script that copies the contents of /home/django to /target, then (c) spawn your regular pod normally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.