Professional Documents
Culture Documents
(/)
PRODUCTS LEARN COMMUNITY SUPPORT FREE TRIAL (HTTPS://WWW.OPENSHIFT.COM/TRIAL/) LOG IN
Documentation (/)
/ OpenShift Container Platform (https://docs.openshift.com/container-platform/4.1/welcome
/index.html) 4.1
/ Nodes / Working with containers (../../nodes/containers/nodes-containers-using.html)
/ Using volumes to persist container data
Page history (https://github.com/openshift/openshift-docs/commits/enterprise-4.1/nodes
/containers/nodes-containers-volumes.adoc) / Suggest an edit (https://github.com/openshift
/openshift-docs/issues/new?title=[enterprise-4.1] Edit suggested in file nodes/containers/nodes-
containers-volumes.adoc)
Understanding volumes
Volumes are mounted file systems available to pods and their
containers which may be backed by a number of host-local or network
attached storage endpoints. Containers are not persistent by default;
on restart, their contents are cleared.
To ensure that the file system on the volume contains no errors and, if
errors are present, to repair them when possible, OpenShift Container
Platform invokes the fsck utility prior to the mount utility. This occurs
when either adding a volume or updating an existing volume.
Object selection
Specify one of the following for object_seletion in the
oc set volume command:
Operation
Specify --add, --remove, or --list for operation in the
oc set volume command.
Mandatory parameters
Any <mandatory_parameters> are specific to the selected operation
and are discussed in later sections.
Options
Any <options> are specific to the selected operation and are
discussed in later sections.
Procedure
To list volumes:
For example:
For example:
Procedure
Updating existing volumes using the --overwrite option:
For example:
Procedure
To remove a volume from pod templates:
For example:
1. View the list of files in the volume, run the oc rsh command:
$ oc rsh <pod>
sh-4.2$ ls /path/to/volume/subpath/mount
example_file1 example_file2 example_file3
apiVersion: v1
kind: Pod
metadata:
name: my-site
spec:
containers:
- name: mysql
image: mysql
volumeMounts:
- mountPath: /var/lib/mysql
name: site-data
subPath: mysql 1
- name: php
image: php
volumeMounts:
- mountPath: /var/www/html
name: site-data
subPath: html 2
volumes:
- name: site-data
persistentVolumeClaim:
claimName: my-site-data
5 of 5 10/17/19, 8:35 AM