Chapter 8. Create Persistent Storage for the Registry
The registry that you created in the previous step stores images and metadata, and uses an ephemeral volume for any pod deployment if persistent storage is not configured. This ephemeral volume is destroyed when the pod exits, losing all data, including any images built or pushed into the registry.
To configure persistent storage for the registry:
- provision a volume that points to a storage server on your network (we will just create it on the master)
- create a volume claim.
- manually add the claim to the registry service.
The following steps to configure persistent storage for the registry apply to storage for any image that requires persistent data and not just for the registry. The registry is just another image in the OpenShift environment.
8.1. Provision the Persistent Volume
Create a registry volume file on your master, as shown here, and call it registry-volume.yaml;
apiVersion: v1 kind: PersistentVolume metadata: name: registry-volume spec: capacity: storage: 3Gi accessModes: - ReadWriteMany nfs: path: /root/storage server: master.openshift.example.com
The folder /root/storage must exist. Make sure to change the server entry to point to your master.
Create the registry persistent volume in OpenShift:
$ oc create -f registry-volume.yaml
8.2. Create the Persistent Volume Claim
Create a claim to bind the persistent volume created earlier. This claim is what ties the registry service to the persistent volume.
Create another file called registry-volume-claim.yaml:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: registry-volume-claim spec: accessModes: - ReadWriteMany resources: requests: storage: 3GiCreate the claim:
$ oc create -f registry-volume-claim.yaml
You have now created the Persistent Volume and the Persistent Volume Claim, and now need to add this claim to the registry.
8.3. Add the Claim to the Registry
$ oc volume dc/docker-registry --add --overwrite -t persistentVolumeClaim --claim-name=registry-volume-claim --name=registry-storageThe docker-registry will now use the 3 GB persistent volume created above for storing image and metadata.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.