Upstream docker allows you to specify a “built-in” VOLUME in an image and it provides a volume for your container when it is run. The content directory for this volume is created on the host under the /var/lib/docker/volumes directory. However, when one tries to use built-in VOLUMEs in kubernetes, there is no guarantee that the data will be persisted. kubernetes has rich support for various kinds of volumes and it is best to use one of those types for your application.
The question becomes how should a container runtime handle image VOLUMEs in k8s. We added support in cri-o to allow cluster administrators to choose what they want to do with such volumes. The three supported options are:
- ignore: cri-o ignores all VOLUMEs and print warnings in the log.
- mkdir: cri-o creates a directory for the VOLUME in the container’s root filesystem.
- bind: cri-o bind mounts a directory for the VOLUME.
To use this feature, pass the flag
--image-volumes=(ignore|mkdir|bind)to the cri-o daemon command line or configure it in your /etc/crio/crio.conf file by changing the
image_volumesproperty under the
[crio.image]section of the file. The default setting is