All Products
Document Center

Elastic Container Instance:Pull an image from Docker Hub to create an elastic container instance

Last Updated:Mar 08, 2024

By default, Elastic Container Instance does not provide external Internet links to pull images from the Internet. Therefore, when you pull images from external image repositories such as Docker Hub to create elastic container instances, the instances must have the ability to access the Internet. This topic describes how to pull an image from Docker Hub to create an elastic container instance. Docker Hub is a hosted repository service provided by Docker.


  • 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 pulling an image from Docker Hub 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 a container.

    1. Enter a name for the container.

    2. Select an image and an image tag.

      Click Select Container Image. On the Docker Official Images tab, find busybox and click Use on the right. Click Select Image Tag and then select latest in the Image Tag dialog box.

      • By default, the image pulling policy (imagePullPolicy) is IfNotPresent. IfNotPresent indicates that on-premises images are preferentially used and images are pulled only if no on-premises images are available.

      • Images whose source is DOCKER_HUB are stored in Docker Hub and must be pulled over the Internet.

    3. Configure startup commands for containers.

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


  5. If no NAT gateway is created for the selected VPC, click Next: Other Settings and associate an elastic IP address (EIP) with the instance.

    In the EIP section, select Auto Create or Use Existing. After an EIP is associated with the instance, the instance can access the Internet through the EIP and Internet-based access to the instance through the EIP is also allowed.

    • Auto Create: The EIPs that are automatically created are billed on a pay-as-you-go basis. You can use EIP bandwidth plans to offset bills of EIPs. You must configure a peak bandwidth.

    • Use Existing: You can select a previously created EIP which is not associated with the instance from the drop-down list.


    By default, Elastic Container Instance does not provide external Internet links to pull public images. If you want to pull images from Docker Hub or other external image repositories, you must create a NAT gateway in the VPC and configure Source Network Address Translation (SNAT), or bind an EIP to the elastic container instance. Otherwise, the image fails to be pulled. For more information, see Enable Internet access.

  6. Click Confirm Configuration.

  7. 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.