All Products
Search
Document Center

Elastic Container Instance:Use coredump to analyze instance program exceptions

Last Updated:Oct 22, 2025

A core dump occurs when a program terminates abnormally or crashes. The operating system dumps the program's memory content into a file for later debugging and analysis. This topic describes how to enable coredump for an Elastic Container Instance (ECI). When a container terminates abnormally, you can view and analyze the generated core file to find the cause of the problem and fix the program.

Background information

In Linux, if a program terminates unexpectedly or crashes, the operating system records the program's memory state at that time and saves it to a file. This action is called a core dump. You can then view and analyze the generated core file to determine the cause of the problem.

The following figure shows the signals that support coredump in Linux. The Action for these signals is Core.

For more information, see coredump file.

Function overview

By default, coredump is disabled for ECI instances to prevent service unavailability that can be caused by excessive disk usage. You can enable coredump in one of the following ways as needed:

  • Method 1: Enable a coredump O&M task

    After you manually enable coredump, an O&M task is generated. When a container terminates abnormally or exits, the triggered coredump automatically saves the generated core file to Object Storage Service (OSS).

  • Method 2: Customize the save path for core files

    You can save core files to external storage. After you set the save path, coredump is automatically enabled. When a container terminates abnormally or exits, the triggered coredump saves the generated core file to the specified path in the external storage.

Note
  • Method 1 is easy to use but has limitations on its validity period and the regions where it is available. It is suitable for temporary program debugging and diagnostics.

    • The generated O&M task is a one-time task. After the task runs successfully and retrieves a core file, coredump is disabled. The O&M task is valid for 12 hours. After this period, the task becomes invalid.

    • This method is not supported in the following regions: China (Ulanqab), China (Heyuan), China (Guangzhou), China (Nanjing - Local Region) (decommissioning), Philippines (Manila), South Korea (Seoul), and Thailand (Bangkok).

  • Method 2 requires you to configure external storage. If a program is unstable, this method ensures that core files can be retrieved. However, if the program has issues, repeated restarts may generate many core files.

Method 1: Enable a coredump O&M task

Console

  1. Log on to the Elastic Container Instance console.

  2. Enable coredump for the ECI instance.

    1. Click the ID of the target instance to go to the instance details page.

    2. Click the O&M tab, select the Coredump tab, and then click Enable.

      After coredump is enabled, an O&M task is generated. If coredump is not triggered, the task status is Pending.

      coredump-1

  3. Trigger coredump.

    Connect to the ECI instance. In the container, run the sleep 100 command and then press Ctrl+\ to trigger a coredump. The generated core file is automatically saved to OSS.coredump2

  4. Download the core file.

    After a coredump is triggered and a core file is generated, the O&M task status changes to Successful. Click Download in the Results column to save the core file to your local computer.

    coredump-2

    Note

    If the download does not start, check the website permission settings in your browser.

OpenAPI

  1. Enable coredump for the ECI instance.

    Call the CreateInstanceOpsTask operation to create an O&M task. Specify the target ECI instance, set the `OpsType` parameter to coredump, and set the `OpsValue` parameter to enable. This enables coredump. For more information, see CreateInstanceOpsTask.

    Note

    Make sure that the `CorePattern` parameter was not set when the instance was created.

  2. Trigger coredump.

    Connect to the ECI instance. In the container, run the sleep 100 command and then press Ctrl+\ to trigger a coredump. The generated core file is automatically saved to OSS.coredump2

  3. Download the core file.

    Call the DescribeInstanceOpsRecords operation to view the O&M task result. The `ResultContent` in the response contains the URL of the core file in OSS. You can access this URL to download the core file.

Method 2: Customize the save path for core files

Core files are typically used for offline issue analysis. Therefore, you must set the save path for core files to external storage instead of a local path in the container. This prevents the core file from being lost if the container exits. ECI lets you customize the save path for core files. After you set the path, coredump is automatically enabled.

When you call the CreateContainerGroup operation to create an ECI instance, you can pass the `CorePattern` parameter to set the save path for core files. The following table describes the related parameters. For more information, see CreateContainerGroup.

Note

This example uses `NFSVolume`. You must configure the `Volume` parameters based on your actual volume type.

Name

Type

Example

Description

CorePattern

String

/data/dump-a/core

The custom directory to save core dump files.

Important

The path cannot start with a vertical bar (|). You cannot use coredump to configure an executable program.

Volume.N.Name

String

volume1

The name of the volume.

Volume.N.Type

String

NFSVolume

The type of the volume. This topic uses NFSVolume as an example.

Volume.N.NFSVolume.Path

String

/dump

The path of the NFS volume.

Volume.N.NFSVolume.Server

String

143b24****-gfn3.cn-beijing.nas.aliyuncs.com

The address of the NFS server.

If you use Alibaba Cloud File Storage NAS, this is the mount target address of the NAS file system.

Container.N.VolumeMount.N.Name

String

volume1

The name of the volume to mount to the container. The value must be the same as the value of `Volume.N.Name`.

Container.N.VolumeMount.N.MountPath

String

/data/dump-a/

The mount directory.

The content in this directory is overwritten by the content of the volume. Make sure that you enter the correct directory.

The following example shows how to use a NAS file system as external storage:

  1. Create an ECI instance named Instance A, mount a NAS file system, and set the save path for core files.

    When you call the CreateContainerGroup operation to create Instance A, pass the following parameters to mount the /dump/ directory of the NAS file system to the /data/dump-a/ directory of the container and set the save path for core files to /data/dump-a/core.

    ContainerGroupName=test-a
    SecurityGroupId=sg-bp1daxpbz9lzpvvc****
    VSwitchId=vsw-bp1gds63lmlm7ib05****
    # Declare a volume
    Volume.1.Name=volume1
    Volume.1.Type=NFSVolume
    Volume.1.NFSVolume.Path=/dump/
    Volume.1.NFSVolume.Server=143b24****-gfn3.cn-beijing.nas.aliyuncs.com
    # Mount the volume to the container
    Container.1.Name=nginx
    Container.1.Image=registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
    Container.1.VolumeMount.1.Name=volume1
    Container.1.VolumeMount.1.MountPath=/data/dump-a/
    # Set the save path for the core file
    CorePattern=/data/dump-a/core
  2. Trigger a coredump in any directory of the container in Instance A.

    As shown in the following example, run the sleep 100 command in the container and then press the Ctrl and \ keys at the same time to trigger a coredump. The core file is saved to the /data/dump-a/ path in the container.

    coredump4

  3. Release ECI instance A.

  4. Mount the same NAS file system to another ECI instance, Instance B.

    When you call the CreateContainerGroup operation to create Instance B, pass the following parameters to mount the /dump/ directory of the same NAS file system to the /data/dump-b/ directory of the container.

    ContainerGroupName=test-nas-b
    SecurityGroupId=sg-bp1daxpbz9lzpvvc****
    VSwitchId=vsw-bp1gds63lmlm7ib05****
    # Declare a volume
    Volume.1.Name=volume1
    Volume.1.Type=NFSVolume
    Volume.1.NFSVolume.Path=/dump/
    Volume.1.NFSVolume.Server=143b24****-gfn3.cn-beijing.nas.aliyuncs.com
    # Mount the volume to the container
    Container.1.Name=nginx
    Container.1.Image=registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
    Container.1.VolumeMount.1.Name=volume1
    Container.1.VolumeMount.1.MountPath=/data/dump-b/
  5. View the core file in the container of Instance B.

    As shown in the following example, you can find the core file in the /data/dump-b/ path of the container. Because the core file is saved to external storage, it is not lost when Instance A is released. You can still view and analyze the core file.

    coredump5

FAQ

After I trigger a coredump, the download does not start when I click Download in the console. What should I do?

If the download does not start, check the website permission settings in your browser. For example, if you use the Chrome browser, you can grant the permission in the following way:

  1. Open the Elastic Container Instance console. In the address bar of your browser, click the 浏览器图标 icon and select Site Settings.浏览器设置1

  2. Set Insecure Content to Allow.浏览器设置2