Volume
In Hyper, volumes offer high availability, durability, and consistent performance needed to run your workloads. It is a persistent storage service for use with containers. Multiple replicas will be automatically created with each volume in the same region to protect your data from failure.
Volume use the EXT4
filesystem (with more options on the roadmap). Each container is shipped with a default root volume
of 10GB. Additional volumes can be created and attached to containers separately:
New volumes can be created based on an existing snapshot. The new volume begins as an exact replica of the original snapshot (same size):
To mount volumes to a container, use hyper run
.
You can also mount the same volume to different mountpoints of the same container.
You can also create volumes with run
:
Volume size
A volume can be create in sizes between 10 and 50 GB.
Volume lifecycle
Once a volume is attached to a container, it will be associated with the container throughout the container's lifecycle, which means that when you (re)start the container, you don't need to mount the volume again. And it cannot be attached to a different container unless the first attaching container is removed.
However, when you rm
a container, the attached volumes will be automatically unmounted. To remove the auto-created volumes along with a container:
Volume Failover
To failover a volume, you need to stop
or rm
the old container, and launch a new one to mount the volume.
Volumes are constrained by region. There is currently no way for containers to access volumes residing in different regions.
Volume Reuse
Notes on reusing existing volumes: users should pay attention to volume access permissions. For example, if a volume is first mounted in container foo
and then reused in container bar
, the file/directory permissions in the volume will remain the same those set in container foo
. As a result, a change of container users (uid/gid pair) may effect the volume's access rights.
Image Volume Creation
New volumes will be created automatically if VOLUME
section is present in the container image.
You can avoid this by specifying the --noauto-volume
option.
File Volume Initialization
When initializing a volume with a specified source (local or http) that points to a file, the volume destination must also be a file. The destination file will be created automatically if it does not already exist.
However, if the image itself has a directory at the volume's target destination, the container will fail to start. For example, the following command will fail to start the container, because /etc/hosts
is a file source and /mnt
is an existing directory in container image ubuntu:14.04
. The same applies to http/https based remote volume sources also.
Instead, you can avoid the failure by specifying a non-directory place to mount the source file, e.g.:
Shared Volumes
Shared volumes are provided using the --volumes-from
option.
You need to create a container using hyperhq/nfs-server
image. It runs an optimized nfs-ganesha server and automatically exports all attached volumes via NFS protocol. Once ready, you can mount the exposed volumes in other containers using the --volumes-from
option.
For example,the following commands expose two volumes (/data1
and /data2
), and mount them in two busybox
containers (test1
and test2
). test1
and test2
will each have these two volumes mounted at the path /data
and /data2
.
NOTE: Recursive mounting is not allowed, e.g. you cannot re-mount the NFS volumes from containers
test1
andtest2
to a third onetest3
:
NOTE:
--volumes-from
source container must be created with the Hyper official image (hyperhq/nfs-server
). Trying to import volumes from containers of other images will fail, e.g.,
NOTE: Your
hyper/nfs-server
container should have enough resources to run the nfs service properly. We recommend creating it with at leasts3
size. If you use too small containers, it may be work just fine at first but can fail with OOM if your workload rises. To see a list of size choises when creating a container, seehyper run --help
.
Last updated