Mounting host data volumes to a Docker container
Mount host data volumes to a Docker container in the Kubernetes YAML file.
About this task
Docker supports the mounting of one or more data volumes from the host OS to the Docker container. Follow this procedure to mount host data volumes to a Docker container by defining the volumes and volumeMounts parameters in the Kubernetes YAML file.
Procedure
Define the path to the host directory under the volumes parameter,
and the path to the container directory under the volumeMounts
parameter in the Kubernetes YAML file:
kind: ReplicationController
apiVersion: v1
metadata:
spec:
replicas: 1
selector:
template:
metadata:
spec:
containers:
- name: sym-primary
image: sym711
command:
volumeMounts:
- name: data
mountPath: /data
readOnly: false
- name: java
mountPath: /opt/java
readOnly: true
resources:
requests:
memory: 4096M
limits:
memory: 8192M
volumes:
- name: data
hostPath:
path: /home/jmlv
- name: java
hostPath:
path: /pcc/app/IBM_jdk1.7/Linux-ibm-java-x86_64-70/