Docker Image content not available in POD (Docker/Kubernetes) Docker Image content not available in POD (Docker/Kubernetes) kubernetes kubernetes

Docker Image content not available in POD (Docker/Kubernetes)


(1) You do have live data baked into your image but override it by mounting a volume to the same path. If data is not to be changed during runtime, don't mount a volume. If it is, use another path and copy live data over on initialization of your Pod.

(2) You have a single PVC with ReadWriteOnce, but your PHP deployment is of kind Deployment that can be scaled (you initialize it with 1 replica). As soon as you try to scale it up all its Pods other than the first one will fail because they won't be able to access the same claim with write access.

(3) You have a second deployment and try to reuse the same ReadWriteOnce volume. Same problem as (2) will occur.

Circumvent all of this by spawning your Pods with their own individual PVCs (you can have them built from volumeClaimTemplates) automatically that only belong to a single Pod. Properly initialize each Pod by setting its container data "live"; copy it to the mount where it can be changed during runtime. If you need consistency of files between Pods in different deployments, spin up an in-cluster NFS server to provide ReadWriteMany volumes.