All Products
Search
Document Center

Create an elastic container instance by using a CentOS image

Last Updated: Apr 01, 2021

This topic describes how to create an elastic container instance by using a CentOS image.

Prerequisites

Before you start, make sure that the following requirements are met:

  • Elastic Container Instance and Resource Access Management (RAM) are activated. The related RAM roles are authorized.

  • A VPC and a vSwitch are created. For more information, see Work with VPCs and Work with vSwitches.

    Note

    If you want your elastic container instance to access the Internet, such as pulling images over the Internet, you must bind a NAT gateway to the VPC and configure source network address translation (SNAT) rules or associate an elastic IP address (EIP) with the elastic container instance. Otherwise, you cannot pull images over the Internet. For more information, see Enable Internet access.

  • The CMD command to start a container is prepared. For more information, see Commands and parameters.

Procedure

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

  1. Go to the Elastic Container Instance buy page.

  2. Select a region and a zone.

    As long as your business requirements can be met, we recommend that you select the zone that has sufficient resources. For more information, see Regions and zones.

  3. Select a VPC and a vSwitch.

    After you select the resources, the corresponding information including the CIDR block is displayed on the page.

  4. (Optional) Select an EIP.

  5. Select a security group. Security groups work 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 enable or disable the access to the Internet or internal network and access to or from specific 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 corresponding ports in the security groups. For more information, see Add security group rules.

  6. Configure the container group.

    1. Configure the restart policy.

    2. Enter the name of the container group.

    3. Add a container.

      centos

      The following table describes the key parameters.

      Parameter

      Description

      Example

      Container Name

      Customize a container name. The requirements for the parameter value are displayed on the buy page.

      test

      Image

      Select a container image and the corresponding version based on your needs.

      centos selected on the Common Image tab and 7 as the version

      Image Pulling Policy

      Select an image pulling policy based on your needs.

      • Always: The image is pulled every time a container is created.

      • On-demand: Local images are preferentially used. If no local images exist, this image is pulled

      • Never: Only local images are used.

      Always

      vCPU and Memory

      Specify the vCPUs and memory of the container based on your needs.

      2 vCPU and 4 GiB

      Command

      The command used to start the container.

      Notice

      The startup command is required to ensure that the elastic container instance can run normally.

      sleep 999999

  7. Click Preview.

  8. Confirm the configurations, read and select Elastic Container Instance Service Agreement, and then click Create ECI.

Command output

After the elastic container instance is created, you can view it on the Container Group page.

If you do not specify the command used to start the CentOS-based container and you set the restart policy to Always, the container keeps attempting to restart and stays in the Waiting state.centos1