All Products
Search
Document Center

Elastic Container Instance:Mount stdlog to a pod

Last Updated:Apr 01, 2026

ECI lets you mount the standard output logs (stdlog) of containers as files inside a Pod using the Container Storage Interface (CSI) plug-in. Once mounted, any process in the Pod can read or forward the log files directly from the local filesystem.

How it works

When you apply a CSI volume backed by the stdlogplugin.csi.alibabacloud.com driver, ECI intercepts the standard output stream of each container and writes it as a log file under the volume's mount path. The file is named after the container. A Pod with multiple containers produces one log file per container, all accessible from the same directory.

This approach is useful when your application needs to consume its own logs at runtime — for example, to parse log output, forward logs to a custom pipeline, or integrate with a log collection agent that watches a file path rather than calling the Kubernetes API.

Prerequisites

Before you begin, make sure you have:

  • Root permissions on the Pod. The stdlog CSI plug-in requires root access to bind the log stream to the volume mount point.

  • kubectl configured to communicate with your cluster.

Mount stdlog to a Pod

  1. Create a file named stdlog_demo.yaml with the following content:

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-stdlog-demo
    spec:
      containers:
      - image: registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
        name: test-container
        volumeMounts:
        - mountPath: /cache-test
          name: cache-volume
      volumes:
      - name: cache-volume
        csi:
          driver: stdlogplugin.csi.alibabacloud.com

    The csi.driver field tells ECI to use the stdlog CSI plug-in. The volume is mounted at /cache-test inside the container.

  2. Deploy the Pod:

    kubectl create -f stdlog_demo.yaml
  3. Verify the mount. After the Pod is running, exec into it and list the mount directory:

    kubectl get pod test-stdlog-demo
    kubectl exec -it test-stdlog-demo bash
    ls -l /cache-test
    ls -l /cache-test/test-container

    The /cache-test directory contains one subdirectory per container. In this example, /cache-test/test-container holds the log files for test-container.

    stdlog新.png

What the mounted log files contain

The files in /cache-test/test-container reflect the standard output logs of the container. You can access them using standard file I/O tools from within the Pod:

  • Read with a log collection agent that watches a directory path

  • Parse or forward with an application running inside the Pod

The directory structure follows the pattern /cache-test/<container-name>/, so if your Pod has multiple containers, each container has its own subdirectory under the mount path.