In Docker Compose, when I mount an empty host volume to a location that already has data in the container, than this data is copied to the empty host volume on the first run.
E.g. if I use the nginx image and mount my empty host volume nginx-config
to /etc/nginx
in the nginx container then on the first start of the container everything from /etc/nginx
is copied to my host volume nginx-config
.
Meanwhile I am using Kubernetes and wondering how that's done in kubernetes? When I mount a empty PersistentVolume to an container at /etc/nginx
, nothing is automatically copied to it ):
You need to use an initContainer, mount the volume on a different path and do the copy explicitly.