All Products
Document Center

Elastic Container Instance:Use a CentOS image to create an elastic container instance

Last Updated:Mar 08, 2024

When you use images such as CentOS and Busybox images provided by Elastic Container Instance to create an elastic container instance, you must set the startup command. Otherwise, the instance may remain in the Starting state. This topic describes how to use a CentOS image provided by Elastic Container Instance to create an elastic container instance.


  • Elastic Container Instance and Resource Access Management (RAM) are activated. Your RAM role is granted the required permissions.


    If you create an elastic container instance as a RAM user, you must grant the required permissions to the RAM user. For more information, see Grant permissions to a RAM user.

  • vSwitches and a VPC are created in the region where you want to create an elastic container instance.

    • For information about the regions and zones where Elastic Container Instance is available, see Regions and zones.

    • For information about how to create a VPC and vSwitch, see Create and manage a VPC and Create and manage a vSwitch.


      We recommend that you create multiple vSwitches. This way, you can select multiple vSwitches to implement the multi-zone feature when you create an elastic container instance. This improves the success rate of instance creation.

  • A security group is created. For more information, see Create a security group.

    Security groups serve as virtual firewalls that provide Stateful Packet Inspection (SPI) and packet filtering capabilities to isolate security domains on the cloud. Each elastic container instance must belong to a security group. For more information, see Assign a security group to an elastic container instance.


This section describes the key configurations and steps of using a CentOS image to create an elastic container instance. For some parameters, only the minimum required or default configurations are used.

  1. Go to the elastic container instance buy page.

  2. Configure the basic information of the instance.

    1. Specify the billing method and type of the instance.

      Use the default settings Pay-as-you-go and Regular Instance.

    2. Select the region in which you want to create the elastic container instance.

    3. Select a VPC and a vSwitch.

      We recommend that you select multiple vSwitches to implement the multi-zone feature. The system preferentially creates the instance in a zone where inventory resources are sufficient.

    4. Select a security group. You can configure security group rules to allow or deny access from elastic container instances in a security group to the Internet or a VPC, and access among IP addresses.


      If you want to access elastic container instances in a VPC over the Internet, you must enable corresponding ports in the security group to which the elastic container instances belong. For more information, see Add a security group rule.

  3. Configure the container group.

    1. Specify specifications for the container group.

      In this example, the instance is created by using vCPU and memory specifications. This creation mode provides better elasticity and resource provisioning capabilities. If your business requires special specifications, such as GPU-accelerated instances, you can specify corresponding Elastic Compute Service (ECS) instance types. For more information, see Specify ECS instance types to create an elastic container instance.

    2. Enter a name for the container group.

    3. Select a restart policy.

      The default value is Always, which specifies that the system automatically restarts a container when the container exits.


  4. Configure containers.

    1. Enter a name for the container.

    2. Select an image and an image tag.

      Click Select Container Image. On the Common Images tab, find eci_open/centos and click Use on the right. Click Select Image Tag and then select 7 in the Image Tag dialog box.

      • The default image pulling policy that is specified by the imagePullPolicy parameter is IfNotPresent. IfNotPresent specifies that on-premises images are preferentially used and images are pulled only if no on-premises images are available.

      • Images whose source is ALI_HUB are stored in Alibaba Cloud image repositories. By default, the images are pulled over VPCs.

    3. Configure startup commands for containers.

      To ensure that CenOS containers can run as expected, you must configure a startup command. In this topic, sleep 999999 is used as an example.


  5. Click Confirm Configuration.

  6. Verify the configurations, read and select the terms of service, and then click Confirm Order.

    After the elastic container instance is created, you can view it on the Container Group page and click the instance ID to go to the instance details page.


If you did not configure a startup command for the CentOS container, the container exits immediately after it is started because there is no resident process in the container. If Restart Policy is set to Always, the system keeps trying to restart the container. As a result, the container remains in the Starting state.centos1