By default, Elastic Container Instance does not provide external links to pull public images. When you pull images from external image repositories such as Docker Hub to create an instance, you must enable Internet access for the instance. 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.
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.
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 a vSwitch, see Create a VPC and Create a vSwitch.
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.
Go to the elastic container instance buy page.
Configure the basic information of the instance.
Select the billing method and type of the instance.
Use the default settings Pay-as-you-go and Regular Instance.
Select the region in which the elastic container instance is created.
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.
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.
Configure the container group and quantity.
Select the number of vCPUs and memory size for the container group.
Enter a name for the container group.
Select a restart policy.
The default value is Always, which indicates that the system automatically restarts the container when the container fails.
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.
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.
Enter a name for the container.
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.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 DOCKER_HUB are stored in Docker Hub and must be pulled over the Internet.
Configure startup commands for containers.
To ensure that the Busybox container can run normally, you must configure a startup command for the container. You can set the startup command to
If the selected VPC is not associated with NAT gateways, click Next: Other Settings and associate an EIP with the elastic container instance.
In the EIP section, select Auto Create or Use Existing. After an EIP is associated with the instance, the instance and the Internet can access each other over the EIP.
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 the bills of EIPs. You must configure a peak bandwidth.
Use Existing: You can select a previously created EIP which is not associated from the drop-down list.
By default, Elastic Container Instance does not provide external links to pull public images. To pull images from external image repositories such as Docker Hub, you must enable Internet access. To enable Internet access, you can associate the VPC with a NAT gateway for which an SNAT entry is configured, or associate an EIP with the elastic container instance. For more information, see Enable Internet access.
Click Confirm Configuration.
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 the instance on the Container Group page and click the instance ID to go to the instance details page.