All Products
Document Center

Mount an emptyDir volume

Last Updated: Oct 11, 2021

This topic describes how to mount an emptyDir volume to an elastic container instance.


Virtual Kubelet is deployed in a Kubernetes cluster.


Alibaba Cloud Serverless Kubernetes (ASK) clusters are integrated with Virtual Kubelet. For other types of clusters, you must manually deploy Virtual Kubelet. For more information, see Connect Kubernetes to Elastic Container Instance.

Configuration example

You can mount an emptyDir volume to an elastic container instance in the same way that you mount an emptyDir volume to a Kubernetes instance. The following example shows how to mount an emptyDir volume:

  1. Prepare a YAML configuration file.

    vim empty_dir.yaml

    The following example shows the content of the empty_dir.yaml file.

    apiVersion: v1
    kind: Pod
      name: test-pd
      - image: nginx:latest
        name: test-container
        - mountPath: /cache-test
          name: cache-volume
      - name: cache-volume
        emptyDir: {}
  2. Deploy a pod.

    kubectl create -f empty_dir.yaml
  3. View the mount result.

    Run the ls command to view the file directory in the pod. The mount directory /cache-test of the emptyDir volume was generated in the pod.