All Products
Search
Document Center

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

Last Updated:Dec 28, 2022

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

Prerequisites

The following requirements are met:

  • Elastic Container Instance and Resource Access Management (RAM) are activated. The required permissions are granted to relevant RAM roles.

  • A virtual private cloud (VPC) and vSwitches are created in the region where you want to create an elastic container instance.

Procedure

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. Select 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 the elastic container instance is created.

    3. Select a VPC and a vSwitch.

      To ensure that resources are sufficient to create the elastic container instance, we recommend that you specify multiple zones by selecting multiple vSwitches. The system preferentially creates the elastic container instance in a zone where resources are sufficient.

    4. Select a security group. Security groups function as virtual firewalls that provide Stateful Packet Inspection (SPI) and packet filtering capabilities to isolate security domains on the cloud. You can configure security group rules to allow or deny elastic container instances in security groups access to the Internet or an internal network, and access among IP addresses. For more information, see Overview.

      Note

      If you want to access elastic container instances in VPCs over the Internet, you must enable the required ports in the security group to which the elastic container instance belongs. For more information, see Add a security group rule.

  3. Configure the container group and quantity.

    1. Select the number of vCPUs and memory size for the container group.

    2. Enter a name for the container group.

    3. Select a restart policy.

      The default value is Always, which indicates that the system automatically restarts the container when the container fails.

    4. Specifies whether to automatically match image caches.

      If you select Automatically Match Image Cache, the system matches image caches to accelerate the creation of the instance. If no image cache is matched, the system automatically creates an image cache when the system creates the instance. The image cache can be used to accelerate the creation of future instances that use similar images.

    5. Specify the number of container groups that you want to purchase by setting Quantity.

      If you purchase multiple container groups, an incremental suffix is automatically appended to the name based on the number of container groups that you purchase. For example, if you set Name to test and Quantity to 3, the names of your purchased container groups are test001, test002, and test003.

    Getting started 1
  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.

      Note
      • By default, the image pulling policy (imagePullPolicy) is IfNotPresent. IfNotPresent indicates that local images are preferentially used and images are pulled only if no local 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 normally, you must configure a startup command for the containers in the instance. You can set Startup Command to sleep 999999.

    3
  5. Click Confirm Configuration.

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

Verify the results

After the elastic container instance is created, you can view the instance 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