// Module included in the following assemblies:
//
// * nodes/nodes-containers-volumes.adoc

:_mod-docs-content-type: REFERENCE
[id="nodes-containers-volumes-updating_{context}"]
= About updating volumes and volume mounts in a pod

[role="_abstract"]
You can modify the volumes and volume mounts in a pod.

You can update existing volumes by using the `--overwrite` option:

[source,terminal]
----
$ oc set volume <object_type>/<name> --add --overwrite [options]
----

For example:

* To replace existing volume *v1* for replication controller *r1* with existing
persistent volume claim *pvc1*:
+
[source,terminal]
----
$ oc set volume rc/r1 --add --overwrite --name=v1 --type=persistentVolumeClaim --claim-name=pvc1
----
+
[TIP]
====
You can alternatively apply the following YAML to replace the volume:

.Sample replication controller with persistent volume claim named `pvc1`
[%collapsible]
=====
[source,yaml]
----
kind: ReplicationController
apiVersion: v1
metadata:
  name: example-1
  namespace: example
spec:
  replicas: 0
  selector:
    app: httpd
    deployment: example-1
    deploymentconfig: example
  template:
    metadata:
      labels:
        app: httpd
        deployment: example-1
        deploymentconfig: example
    spec:
      volumes:
        - name: v1
          persistentVolumeClaim:
            claimName: pvc1
      containers:
        - name: httpd
          image: >-
            image-registry.openshift-image-registry.svc:5000/openshift/httpd:latest
          ports:
            - containerPort: 8080
              protocol: TCP
          volumeMounts:
            - name: v1
              mountPath: /data
----
+
The `spec.template.spec.volumes` stanza sets the persistent volume claim to `pvc1`.
=====
====

* To change the `DeploymentConfig` object *d1* mount point to *_/opt_* for volume *v1*:
+
[source,terminal]
----
$ oc set volume dc/d1 --add --overwrite --name=v1 --mount-path=/opt
----
+
[TIP]
====
You can alternatively apply the following YAML to change the mount point:

.Sample deployment config with mount point set to `opt`.
[%collapsible]
=====
[source,yaml]
----
kind: DeploymentConfig
apiVersion: apps.openshift.io/v1
metadata:
  name: example
  namespace: example
spec:
  replicas: 3
  selector:
    app: httpd
  template:
    metadata:
      labels:
        app: httpd
    spec:
      volumes:
        - name: volume-pppsw
          emptyDir: {}
        - name: v2
          persistentVolumeClaim:
            claimName: pvc1
        - name: v1
          persistentVolumeClaim:
            claimName: pvc1
      containers:
        - name: httpd
          image: >-
            image-registry.openshift-image-registry.svc:5000/openshift/httpd:latest
          ports:
            - containerPort: 8080
              protocol: TCP
          volumeMounts:
            - name: v1
              mountPath: /opt
----
+
The `spec.template.spec.containers.volumeMounts` stanza sets the mount point to `/opt`.
=====
====
