Copying a dir. fails


In my Dockerfile
When I copy one dir. to image

#COPY /app /app

Kubernetes failed with “Back-off restarting failed container”

Kubernetes does not fail when I cancel copying.

Can you tell me why?
What do you suggest to copy dir. to kubernetes-pod ?


What do you suggest to copy dir. to kubernetes-pod ?

If you need to update the contents of a volume mounted on a container’s pod, you may use init container; init containers will run before the “main” container in the pod, so it can be used to pull data from a repository, or to curl files from a shared server, etc…

If you are trying to build your image in a pod running in Kubernetes, the COPY instruction will try to copy from <container-file-system>/app to <new-image-file-system>/app. Unless you somehow mount the <k8s-node-file-system>/app directory to your <container-file-system>/app, the build process will fail.

Another reason why the pod may be crash-looping is because Kuberntes is trying to mount the <k8s-node-file-system>/app folder where the pod is running to your <container-file-system>/app as a volume in your container’s pod and failing to do so.

containerd, which is the default container runtime in Kubernetes is not able to create container images; maybe you can “divide and conquer”: first, create the container image for your App using Docker; push it to a container registry (as DockerHub or and then run your app in Kubernetes.

Best regards,


The dockerfile you mention is the one you used to create the container which is crashing?