[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[],[],null,["# Mount external volumes\n======================\n\nThis topic explains how to mount additional volumes to a workload migrated with\nMigrate to Containers. You might want to do this when your workload depends on\nan external volume that is not copied to a Persistent Volume.\n\nTo add external volumes to a Migrate to Containers workload:\n\n1. Add the volume to the `StatefulSet` in `spec.containers.volumeMounts`. See [Kubernetes Volumes](https://kubernetes.io/docs/concepts/storage/volumes/) for more information.\n2. Mount the volume in the container at the mount point you would like. This will vary depending on the container's operating system.\n\nThe example below mounts the volume `emptydir` to `/tmp`. \n\n apiVersion: apps/v1\n kind: StatefulSet\n metadata:\n creationTimestamp: null\n labels:\n app: app-my-vm-instance-1\n migrate-for-anthos-type: workload\n name: app-my-vm-instance-1\n spec:\n replicas: 1\n selector:\n matchLabels:\n app: app-my-vm-instance-1\n migrate-for-anthos-type: workload\n serviceName: app-my-vm-instance-1\n template:\n metadata:\n creationTimestamp: null\n labels:\n app: app-my-vm-instance-1\n migrate-for-anthos-type: workload\n spec:\n containers:\n - image: gcr.io/my-project/my-vm-instance-1:v1.0.0\n name: app-my-vm-instance-1\n readinessProbe:\n exec:\n command:\n - /code/ready.sh\n resources: {}\n securityContext:\n privileged: true\n volumeMounts:\n - name: emptydir\n mountPath: /tmp\n - mountPath: /sys/fs/cgroup\n name: cgroups\n - mountPath: /code/config/logs/\n name: logs-config\n - mountPath: /\u003cfolder\u003e\n name: pvc-my-vm-instance-1\n subPath: \u003cfolder\u003e\n volumes:\n - name: emptydir\n emptyDir: {}\n - hostPath:\n path: /sys/fs/cgroup\n type: Directory\n name: cgroups\n - configMap:\n name: app-my-vm-instance-1\n name: logs-config\n - name: pvc-my-vm-instance-1\n persistentVolumeClaim:\n claimName: pvc-my-vm-instance-1\n updateStrategy: {}\n status:\n replicas: 0\n\nWhat's next\n-----------\n\n- Learn how to [deploy a Linux workload to a target cluster](/migrate/containers/docs/deploying-to-target-cluster)."]]