I have a directory within container A that I would like to share with container B.
For example I have a directory /dataabc
on container A.
I've tried using a shared hostPath
volume, however as this is empty when mounted - it makes the existing files non accessible. (/dataabc
would be mounted on top of the existing /dataabc/
from container A.
I could copy the files over on container startup - but this requires modification to the container. Is there a more simple way that does not require modification to the container?
Big thanks to @graham, I could reuse the existing container with just this minor modification to the pod config:
initContainers:
- args:
- cp -r /var/www / && ls -altr /www/
command:
- /bin/sh
- -c
image: example
imagePullPolicy: Always
name: example-init
volumeMounts:
- mountPath: /www
name: webroot