liveBook · Manning

Docker volume mount

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A volume mount is a container specification that makes a volume available at a path inside the container's filesystem.

A volume mount makes volume-backed data available at a path inside a container. In Kubernetes, the container’s volumeMounts entry names the volume and sets its mountPath. section 7.4

Use volume mounts to expose different kinds of data:

  • Mount an emptyDir volume for temporary storage that lasts for the lifetime of the Pod. section 7.4
  • Mount ConfigMap data into a container when applications need configuration files. section 4.2.4
  • Mount Secret data into a directory, or provide it through environment variables. section 4.2.5

Mount an emptyDir volume at /var/log

Define the same name under the container’s volumeMounts and the Pod’s volumes: volumeMounts: [{mountPath: /var/log, name: logvol}] and volumes: [{name: logvol, emptyDir: {}}]. Create it with kubectl create -f log-collector.yaml, then verify the Running Pod with kubectl get po and the EmptyDir mount with kubectl describe po log-collector. section 7.4

  1 apiVersion: v1
  2 kind: Pod
  3 metadata:
  4   creationTimestamp: null
  5   labels:
  6     run: log-collector
  7   name: log-collector
  8 spec:
  9   containers:
 10   - command:
 11     - sleep
 12     - "3600"
 13     image: busybox
 14     name: log-collector
 15     resources: {}
 16     volumeMounts:
 17     - mountPath: /var/log
 18       name: logvol
 19   dnsPolicy: ClusterFirst
 20   restartPolicy: Always
 21   volumes:
 22   - name: logvol
 23     emptyDir: {}

Inspect the complete Pod manifest showing the matching volume name, mountPath, and emptyDir definition. section 7.4

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Demonstrates YAML fields, creation commands, and kubectl verification for temporary, ConfigMap, and Secret-backed mounts.
Examples
Uses a log collector at /var/log, Redis configuration, and Secret files under /etc/secret-vol.
What it assumes
Assumes familiarity with Pods and YAML while teaching volume names, mount paths, and volume types through commands.
What you can do after
Operate/configure Pod mounts with YAML and kubectl, then verify their status and volume type.
How it connects
Connects volume mounts with Pods, volumes, emptyDir, ConfigMaps, Secrets, and environment variables.

Also explained in

Compare how 2 books explain Docker volume mount →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.